Пример #1
0
        private ProcName ParseProcName( )
        {
            ProcName procName = new ProcName();

            procName.FileContext = this.fileMY.FileContext;
            while (tape.CurrentKind != TokenKind.EOF && tape.CurrentKind != TokenKind.NewLine)
            {
                if (tape.CurrentKind == TokenKind.LBS)
                {
                    var arg = ParseProcArg();
                    if (arg != null)
                    {
                        procName.AddArg(arg);
                    }
                }
                else if (tape.CurrentKind == TokenKind.Ident)
                {
                    procName.AddNamePart(tape.Current);
                    tape.MoveNext();
                }
                else if (tape.CurrentKind == TokenKind.Colon)
                {
                    break;
                }
            }
            return(procName);
        }
        public static int FieldCode_InsertUpdate(string strConn, int?FieldCodeId, int FieldClassId, string FieldCodeName, string FieldCodeAlias,
                                                 string FieldCodeOrder, Guid?CompanyId)
        {
            const string  ProcName   = "FieldCode_InsertUpdate()";
            SqlConnection connection = null;
            SqlParameter  param;
            DateTime      startDate  = DateTime.Now;
            Guid          LoginID    = Guid.Empty;
            string        strMessage = string.Empty;
            DataTable     dt         = new DataTable();
            int           rowsEffected;
            int           returnValue;

            try
            {
                connection = DataSource.GetConnection(strConn);
                using (SqlCommand command = new SqlCommand())
                {
                    command.CommandText = ProcName.Substring(0, ProcName.Length - 2);
                    command.Connection  = connection;
                    command.CommandType = CommandType.StoredProcedure;

                    param       = command.Parameters.Add("@FieldCodeId", SqlDbType.Int);
                    param.Value = FieldCodeId;

                    param       = command.Parameters.Add("@FieldClassId", SqlDbType.Int);
                    param.Value = FieldClassId;

                    param       = command.Parameters.Add("@FieldCodeName", SqlDbType.VarChar);
                    param.Value = FieldCodeName;

                    param       = command.Parameters.Add("@FieldCodeAlias", SqlDbType.VarChar);
                    param.Value = FieldCodeAlias;

                    param       = command.Parameters.Add("@FieldCodeOrder", SqlDbType.VarChar);
                    param.Value = FieldCodeOrder;

                    param       = command.Parameters.Add("@CompanyId", SqlDbType.UniqueIdentifier);
                    param.Value = CompanyId;

                    param           = command.Parameters.Add("@ReturnValue", SqlDbType.Int);
                    param.Direction = ParameterDirection.ReturnValue;

                    rowsEffected = command.ExecuteNonQuery();

                    returnValue = (int)command.Parameters["@ReturnValue"].Value;
                }
            }
            finally
            {
                DataSource.CloseConnection(connection);

                TimeSpan timeSpan = DateTime.Now.Subtract(startDate);
            }
            return(returnValue);
        }
Пример #3
0
 /// <summary>
 /// DataDic窗体refresh事件。
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 public virtual void cmd_refresh_ClickEvent(object sender, System.EventArgs e)
 {
     if (ProcName.CompareTo("") > 0)
     {
         Gf_DD_ReSelctDisp(GeneralCommon.M_CN1, "{call " + ProcName + "(" + ReComposeProcParam() + ")}", false);
     }
     else
     {
         Gf_DD_ReSelctDisp(GeneralCommon.M_CN1, QuerySQL + ReComposeWhereSQL(), false);
     }
 }
Пример #4
0
        /// <summary>
        /// Converts to string.
        /// </summary>
        /// <returns>
        /// A <see cref="string" /> that represents this instance.
        /// </returns>
        public override string ToString()
        {
            var formalsString = string.Join(", ", Formals.Select(f => $"({f.ToString()})"));
            var localsString  = string.Join(", ", Locals.Select(l => $"{l.ToString()}"));

            return($@"{{
ProcName: {ProcName.ToString()}
Access: {Access.ToString()}
Formals: {formalsString}
Location: {Loc.ToString()}
Locals: {localsString}
ReturnType: {RetType.ToString()}
}}");
        }
Пример #5
0
        /// <summary>
        /// DataDic窗体加载事件。
        ///1设置页面的位置信息。
        ///2调用ComposeWhereSQL(),生成完整where语句。
        ///3 调用ssResult_Init(),ssWhere_Init()函数,初始化窗体,将sql语句传到数据库执行,并将结果返回到窗体中。
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void DataDic_Load(object sender, System.EventArgs e)
        {
            GeneralCommon.Gp_FormLoc_Get(this, "ETC");


            if (ProcName.CompareTo("") > 0)
            {
                Gf_DD_ReSelctDisp(GeneralCommon.M_CN1, "{call " + ProcName + "(" + ComposeProcParam() + ")}", false);
            }
            else
            {
                ComposeWhereSQL();
                Gf_DD_ReSelctDisp(GeneralCommon.M_CN1, QuerySQL + " " + ComposeWhereSQL(), false);
            }


            this.KeyPreview = true;

            this.DataDic_Activated(sender, e);
        }
Пример #6
0
        public static int  Delete_Process(string strConn, int ProcessId)
        {
            const string  ProcName   = "PROCESS_Delete()";
            SqlConnection connection = null;
            SqlParameter  param;
            DateTime      startDate  = DateTime.Now;
            Guid          LoginID    = Guid.Empty;
            string        strMessage = string.Empty;
            DataTable     dt         = new DataTable();
            int           rowsEffected;
            int           returnValue;

            try
            {
                connection = DataSource.GetConnection(strConn);
                using (SqlCommand command = new SqlCommand())
                {
                    command.CommandText = ProcName.Substring(0, ProcName.Length - 2);
                    command.Connection  = connection;
                    command.CommandType = CommandType.StoredProcedure;

                    param       = command.Parameters.Add("@ProcessId", SqlDbType.Int);
                    param.Value = ProcessId;

                    param           = command.Parameters.Add("@ReturnValue", SqlDbType.Int);
                    param.Direction = ParameterDirection.ReturnValue;

                    rowsEffected = command.ExecuteNonQuery();
                    returnValue  = (int)command.Parameters["@ReturnValue"].Value;
                }
            }
            finally
            {
                DataSource.CloseConnection(connection);

                TimeSpan timeSpan = DateTime.Now.Subtract(startDate);
            }
            return(returnValue);
        }
Пример #7
0
        /// <summary>
        /// The cdata inner-text of the sql-query hbm.xml node.
        /// </summary>
        /// <returns></returns>
        public string ToHbmSql()
        {
            var hbmSql = new StringBuilder();

            hbmSql.AppendLine();
            hbmSql.Append(EXEC);
            if (ProcName.Contains("."))
            {
                //schema names may have periods within them looking like [my.schema].[MyStoredProc]
                //so put braces around everything to the left and right of the last period
                var procNameParts = ProcName.Split('.').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
                if (procNameParts.Count == 1)
                {
                    hbmSql.AppendFormat("[{0}]", procNameParts[0]);
                }
                else if (procNameParts.Count == 2)
                {
                    hbmSql.AppendFormat("[{0}].[{1}]", procNameParts[0], procNameParts[1]);
                }
                else
                {
                    var leftSide  = string.Format("[{0}]", string.Join(".", procNameParts.Take(procNameParts.Count - 1)));
                    var rightSide = string.Format("[{0}]", procNameParts[(procNameParts.Count - 1)]);
                    hbmSql.AppendFormat("{0}.{1}", leftSide, rightSide);
                }
            }
            else
            {
                hbmSql.AppendFormat("[{0}]", ProcName);
            }
            hbmSql.AppendLine();
            if (Parameters != null && Parameters.Count > 0)
            {
                hbmSql.AppendLine(string.Join(",\n", Parameters.Select(x => x.ParamName.Replace("@", "\t:"))));
            }
            return(hbmSql.ToString());
        }
Пример #8
0
        private void ParseRequest(string requestMethod, string thePath, string rawUrl, string soapAction)
        {
            string requestPath = thePath.Substring(1);

            DadSpecifiedInRequest = true;
            IsFlexibleParams      = false;
            IsPathAlias           = false;

            string[] pathElements = requestPath.Split('/');

            if (pathElements.Length >= 2)
            {
                ModuleName = pathElements[0];
                DadName    = pathElements[1];

                if (DadName.Length == 0 || !DadConfiguration.IsValidDad(DadName))
                {
                    DadSpecifiedInRequest = false;
                    DadName = DadConfiguration.DefaultDad;
                }

                // get dad-specific configuration settings
                DadConfig = new DadConfiguration(DadName);

                if (pathElements.Length >= 3)
                {
                    ProcName = pathElements[2];
                    if (ProcName.Length > 0)
                    {
                        if (ProcName.Substring(0, 1) == "!")
                        {
                            IsFlexibleParams = true;
                        }
                        else if (ProcName == DadConfig.PathAlias)
                        {
                            IsPathAlias    = true;
                            PathAliasValue = GetAliasValue(ProcName, thePath);
                        }
                        else if (ProcName == DadConfig.XdbAlias)
                        {
                            IsXdbAlias    = true;
                            XdbAliasValue = GetAliasValue(ProcName, thePath);
                        }
                        else if (ProcName == DadConfig.DocumentPath)
                        {
                            IsDocumentPath = true;
                        }
                    }
                }
                else
                {
                    // missing trailing slash in request
                    ProcName = "";
                }

                if (ProcName.Length == 0)
                {
                    ProcName = DadConfig.DefaultPage;
                }

                if (DadConfig.InvocationProtocol == DadConfiguration.INVOCATION_PROTOCOL_SOAP)
                {
                    IsSoapRequest = true;
                    IsWsdlRequest = requestMethod.ToUpper() == "GET" && rawUrl.ToLower().EndsWith("?wsdl");
                }

                if (IsSoapRequest && !IsWsdlRequest)
                {
                    // get the procedure name from the SOAPAction header
                    string methodName = soapAction.Replace("\"", "");
                    methodName = methodName.Substring(methodName.LastIndexOf("/") + 1);
                    ProcName   = ProcName + "." + StringUtil.ReversePrettyStr(methodName);
                }

                ProcName = SanitizeProcName(ProcName, DadConfig.ExclusionList);
            }
            else
            {
                ModuleName = "";
                DadName    = "";
                ProcName   = "";
            }

            if (DadName.Length > 0 && ProcName.Length > 0)
            {
                string[] urlProcElements = ProcName.Split('.');

                if (urlProcElements.Length == 3)
                {
                    // schema, package and procedure specified
                    OraSchema  = urlProcElements[0];
                    OraPackage = urlProcElements[1];
                    OraProc    = urlProcElements[2];
                }
                else if (urlProcElements.Length == 2)
                {
                    // assume package and procedure specified (although it could also be schema and procedure, but there is no way to be certain)
                    OraSchema  = "";
                    OraPackage = urlProcElements[0];
                    OraProc    = urlProcElements[1];
                }
                else
                {
                    // just the procedure is specified
                    OraSchema  = "";
                    OraPackage = "";
                    OraProc    = ProcName;
                }

                logger.Debug("Parsed module = " + ModuleName + ", dad = " + DadName + ", proc = " + ProcName);
            }
        }
Пример #9
0
        public static int Rights_InsertUpdate(string strConn, int?RoleRightsId, int RoleId, int ModuleId, bool View, bool Edit, bool Create, bool Delete, Guid?CompanyId)
        {
            const string  ProcName   = "RoleRights_InsertUpdate()";
            SqlConnection connection = null;
            SqlParameter  param;
            DateTime      startDate  = DateTime.Now;
            Guid          LoginID    = Guid.Empty;
            string        strMessage = string.Empty;
            DataTable     dt         = new DataTable();
            int           rowsEffected;
            int           returnValue;

            try
            {
                connection = DataSource.GetConnection(strConn);
                using (SqlCommand command = new SqlCommand())
                {
                    command.CommandText = ProcName.Substring(0, ProcName.Length - 2);
                    command.Connection  = connection;
                    command.CommandType = CommandType.StoredProcedure;

                    param       = command.Parameters.Add("@RoleRightsId", SqlDbType.Int);
                    param.Value = RoleRightsId;

                    param       = command.Parameters.Add("@RoleId", SqlDbType.Int);
                    param.Value = RoleId;

                    param       = command.Parameters.Add("@ModuleId", SqlDbType.Int);
                    param.Value = ModuleId;

                    param       = command.Parameters.Add("@View", SqlDbType.Bit);
                    param.Value = View;

                    param       = command.Parameters.Add("@Edit", SqlDbType.Bit);
                    param.Value = Edit;

                    param       = command.Parameters.Add("@Create", SqlDbType.Bit);
                    param.Value = Create;

                    param       = command.Parameters.Add("@Delete", SqlDbType.Bit);
                    param.Value = Delete;

                    param       = command.Parameters.Add("@CompanyId", SqlDbType.UniqueIdentifier);
                    param.Value = CompanyId;

                    param           = command.Parameters.Add("@ReturnValue", SqlDbType.Int);
                    param.Direction = ParameterDirection.ReturnValue;

                    rowsEffected = command.ExecuteNonQuery();

                    returnValue = (int)command.Parameters["@ReturnValue"].Value;
                }
            }
            finally
            {
                DataSource.CloseConnection(connection);

                TimeSpan timeSpan = DateTime.Now.Subtract(startDate);
            }
            return(returnValue);
        }
Пример #10
0
        public static int ProductInsert(string strConn, int?Productid, string ProductName, int UOM,
                                        int Colour, int Texture, Guid CreatedBy, string Processid, int BuyProductId, int BuyProductPacking, int Catagory,
                                        Guid CompanyId)
        {
            const string  ProcName   = "ProductMaster_InsertUpdate()";
            SqlConnection connection = null;
            SqlParameter  param;
            DateTime      startDate  = DateTime.Now;
            Guid          LoginID    = Guid.Empty;
            string        strMessage = string.Empty;
            DataTable     dt         = new DataTable();
            int           rowsEffected;
            int           returnValue;

            try
            {
                connection = DataSource.GetConnection(strConn);
                using (SqlCommand command = new SqlCommand())
                {
                    command.CommandText = ProcName.Substring(0, ProcName.Length - 2);
                    command.Connection  = connection;
                    command.CommandType = CommandType.StoredProcedure;

                    param       = command.Parameters.Add("@Productid", SqlDbType.Int);
                    param.Value = Productid;

                    param       = command.Parameters.Add("@ProductName", SqlDbType.VarChar);
                    param.Value = ProductName;

                    param       = command.Parameters.Add("@UOM", SqlDbType.Int);
                    param.Value = UOM;



                    param       = command.Parameters.Add("@Colour", SqlDbType.Int);
                    param.Value = Colour;

                    param       = command.Parameters.Add("@Texture", SqlDbType.Int);
                    param.Value = Texture;

                    param       = command.Parameters.Add("@CreatedBy", SqlDbType.UniqueIdentifier);
                    param.Value = CreatedBy;

                    param       = command.Parameters.Add("@ProcessId", SqlDbType.VarChar);
                    param.Value = Processid;



                    param       = command.Parameters.Add("@BuyProductId", SqlDbType.Int);
                    param.Value = BuyProductId;
                    param       = command.Parameters.Add("@Catagory", SqlDbType.Int);
                    param.Value = Catagory;

                    param       = command.Parameters.Add("@BuyProductPacking", SqlDbType.Int);
                    param.Value = BuyProductPacking;

                    param           = command.Parameters.Add("@CompanyId", SqlDbType.UniqueIdentifier);
                    param.Value     = CompanyId;
                    param           = command.Parameters.Add("@ReturnValue", SqlDbType.Int);
                    param.Direction = ParameterDirection.ReturnValue;


                    rowsEffected = command.ExecuteNonQuery();
                    returnValue  = (int)command.Parameters["@ReturnValue"].Value;
                }
            }
            finally
            {
                DataSource.CloseConnection(connection);

                TimeSpan timeSpan = DateTime.Now.Subtract(startDate);
            }
            return(returnValue);
        }
Пример #11
0
        public static int UOMMaster_InsertUpdate(string strConn, int UOMId, int UOMTypeId, string UOMName, string UOMCode,
                                                 int DecimalPoints, bool BaseUnit, decimal ConversionRation, Guid?CreatedBy, Guid?ModifiedBy, Guid?CompanyId)
        {
            const string  ProcName   = "UOMMaster_InsertUpdate()";
            SqlConnection connection = null;
            SqlParameter  param;
            DateTime      startDate  = DateTime.Now;
            Guid          LoginID    = Guid.Empty;
            string        strMessage = string.Empty;
            DataTable     dt         = new DataTable();
            int           rowsEffected;
            int           returnValue;

            try
            {
                connection = DataSource.GetConnection(strConn);
                using (SqlCommand command = new SqlCommand())
                {
                    command.CommandText = ProcName.Substring(0, ProcName.Length - 2);
                    command.Connection  = connection;
                    command.CommandType = CommandType.StoredProcedure;

                    param       = command.Parameters.Add("@UOMId", SqlDbType.Int);
                    param.Value = UOMId;

                    param       = command.Parameters.Add("@UOMTypeId", SqlDbType.Int);
                    param.Value = UOMTypeId;

                    param       = command.Parameters.Add("@UOMName", SqlDbType.VarChar);
                    param.Value = UOMName;

                    param       = command.Parameters.Add("@UOMCode", SqlDbType.VarChar);
                    param.Value = UOMCode;

                    param       = command.Parameters.Add("@DecimalPoints", SqlDbType.Int);
                    param.Value = DecimalPoints;

                    param       = command.Parameters.Add("@BaseUnit", SqlDbType.Bit);
                    param.Value = BaseUnit;

                    param       = command.Parameters.Add("@ConversionRation", SqlDbType.Decimal);
                    param.Value = ConversionRation;

                    param       = command.Parameters.Add("@CreatedBy", SqlDbType.UniqueIdentifier);
                    param.Value = CreatedBy;

                    param       = command.Parameters.Add("@ModifiedBy", SqlDbType.UniqueIdentifier);
                    param.Value = ModifiedBy;

                    param       = command.Parameters.Add("@CompanyId", SqlDbType.UniqueIdentifier);
                    param.Value = CompanyId;

                    param           = command.Parameters.Add("@ReturnValue", SqlDbType.Int);
                    param.Direction = ParameterDirection.ReturnValue;

                    rowsEffected = command.ExecuteNonQuery();

                    returnValue = (int)command.Parameters["@ReturnValue"].Value;
                }
            }
            finally
            {
                DataSource.CloseConnection(connection);

                TimeSpan timeSpan = DateTime.Now.Subtract(startDate);
            }
            return(returnValue);
        }
Пример #12
0
        public static int ProcessInsert(string strConn, int?ProcessId, string ProcessName, bool QuantityFlag,
                                        bool PackingFlag, String ProcessDuration, float ProcessVolume, bool WastageFlag, int ProcessUnit, Guid?CompanyId, bool byProduct)
        {
            const string  ProcName   = "ProcessMaster_InserUpdate()";
            SqlConnection connection = null;
            SqlParameter  param;
            DateTime      startDate  = DateTime.Now;
            Guid          LoginID    = Guid.Empty;
            string        strMessage = string.Empty;
            DataTable     dt         = new DataTable();
            int           rowsEffected;
            int           returnValue;

            try
            {
                connection = DataSource.GetConnection(strConn);
                using (SqlCommand command = new SqlCommand())
                {
                    command.CommandText = ProcName.Substring(0, ProcName.Length - 2);
                    command.Connection  = connection;
                    command.CommandType = CommandType.StoredProcedure;

                    param       = command.Parameters.Add("@ProcessId", SqlDbType.Int);
                    param.Value = ProcessId;


                    param       = command.Parameters.Add("@ProcessName", SqlDbType.VarChar);
                    param.Value = ProcessName;


                    param       = command.Parameters.Add("@QuantityFlag", SqlDbType.Bit);
                    param.Value = QuantityFlag;

                    param       = command.Parameters.Add("@PackingFlag", SqlDbType.Bit);
                    param.Value = PackingFlag;
                    param       = command.Parameters.Add("@ProcessDuration", SqlDbType.Time);
                    param.Value = ProcessDuration;
                    param       = command.Parameters.Add("@WastageFlag", SqlDbType.Bit);
                    param.Value = WastageFlag;
                    param       = command.Parameters.Add("@QuantityFlag", SqlDbType.Bit);
                    param.Value = QuantityFlag;

                    param       = command.Parameters.Add("@ByProduct", SqlDbType.Bit);
                    param.Value = byProduct;
                    param       = command.Parameters.Add("@ProcessVolume", SqlDbType.Float);
                    param.Value = ProcessVolume;

                    param       = command.Parameters.Add("@CompanyId", SqlDbType.UniqueIdentifier);
                    param.Value = CompanyId;

                    param           = command.Parameters.Add("@ReturnValue", SqlDbType.Int);
                    param.Direction = ParameterDirection.ReturnValue;
                    param           = command.Parameters.Add("@ProcessUnit", SqlDbType.Int);
                    param.Value     = ProcessUnit;

                    rowsEffected = command.ExecuteNonQuery();
                    returnValue  = (int)command.Parameters["@ReturnValue"].Value;
                }
            }
            finally
            {
                DataSource.CloseConnection(connection);

                TimeSpan timeSpan = DateTime.Now.Subtract(startDate);
            }
            return(returnValue);
        }
Пример #13
0
        static void Main(string[] args)
        {
            Application.SetHighDpiMode(HighDpiMode.SystemAware);
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(UnhandledExceptionMessageBox);
            Application.ThreadException += new ThreadExceptionEventHandler(UIThreadUnhandledExceptionMessageBox);

            TheMutex = new Mutex(true, "GFEAppManager");

            if (!TheMutex.WaitOne(TimeSpan.Zero, true))
            {
                MessageBox.Show(owner: null, text: "An instance of application is already running!", caption: "Error", buttons: MessageBoxButtons.OK, icon: MessageBoxIcon.Error);
                System.Environment.Exit(1);
            }

            if (args.Length >= 1)
            {
                if (args[0] == "startup")
                {
                    // Lets make sure that the tray icon is visible after login by restarting the app with significant delay
                    ProcessStartInfo Info    = new ProcessStartInfo();
                    string           ThePath = System.Reflection.Assembly.GetExecutingAssembly().Location.Remove(System.Reflection.Assembly.GetExecutingAssembly().Location.Length - 4) + ".exe";
                    Info.Arguments      = "/C ping 127.0.0.1 -n 4 && start \"\" \"" + ThePath + "\"";
                    Info.WindowStyle    = ProcessWindowStyle.Hidden;
                    Info.CreateNoWindow = true;
                    Info.FileName       = "cmd.exe";
                    Process.Start(Info);
                    System.Environment.Exit(0);
                }
            }

            try
            {
                TheServiceOperations.CheckService();
            } catch (InvalidOperationException)
            {
                MessageBox.Show(owner: null, text: "Could not find the GeForce® Experience™ service!", caption: "Error", buttons: MessageBoxButtons.OK, icon: MessageBoxIcon.Error);
                System.Environment.Exit(1);
            }

            try
            {
                string[] Lines = File.ReadAllLines(ConfigFileLocation);

                foreach (string ProcName in Lines)
                {
                    if (!ProcName.EndsWith(".exe"))
                    {
                        MessageBox.Show(owner: null, text: "You need to enter a process with .exe extension!", caption: "Error", buttons: MessageBoxButtons.OK, icon: MessageBoxIcon.Error);
                        System.Environment.Exit(1);
                    }

                    if (ListOfApplicationsToDisableService.Keys.Any(x => x.ToLower() == ProcName.ToLower()))
                    {
                        MessageBox.Show(owner: null, text: "The process is already in list!", caption: "Error", buttons: MessageBoxButtons.OK, icon: MessageBoxIcon.Error);
                        System.Environment.Exit(1);
                    }

                    ListOfApplicationsToDisableService.TryAdd(ProcName, ProcName);
                }
            } catch (FileNotFoundException)
            {
                // Default example app list
                ListOfApplicationsToDisableService.TryAdd("vmplayer.exe", "vmplayer.exe");
                ListOfApplicationsToDisableService.TryAdd("WindowsTerminal.exe", "WindowsTerminal.exe");
                SaveConfigFile();
            }

            TheMainAppContext = new MainAppContext();

            TheServiceOperations.BeginListening();

            Application.Run(TheMainAppContext);
        }