Example #1
1
    protected void Page_Load(object sender, EventArgs e)
    {
	conn = new Connection();
        string connectionstring = ConfigurationManager.ConnectionStrings["connectionstring"].ConnectionString;
        conn.Open(connectionstring); 
        Recordset Rs1 = null;
    object StationID = null;
    object UserID = null;
    object SecLevel = null;
    string Barcode = "";
    string ProductType = "";
    string CarPlate = "";
    string Message = "";

    Rs1 = new Recordset();
    StationID = Session["StationID"];
    UserID = Session["UserID"];
    SecLevel = Session["SecLevel"];
    Barcode = Request["Barcode"];
    ProductType = Request["ProductType"];
    CarPlate = Request["CarPlate"];
    Message = "ÅçÃÒ¦¨¥\\!";
    Rs1.Open(("Exec InsertCoupon '" + Barcode + "', '" + Convert.ToString(StationID) + "','" + ProductType + "','" + CarPlate + "','" + Convert.ToString(UserID) + "' "), conn, (nce.adodb.CursorType)3, (nce.adodb.LockType)1);
   
    Response.Redirect("CouponVerification.aspx?Message=" + Message + "&CarPlate=" + CarPlate + "&ProductType=" + ProductType);
    }
        public static Connection GetConnection(ServiceContext context)
        {
            Connection conn = new Connection();

            ConnectionSetup conSetup = new ConnectionSetup();

            conSetup.ConnectionParameters.Add(ConnectionSetup.ParamKeys.Host, context[SettingVariable.ServerName]);
            conSetup.ConnectionParameters.Add(ConnectionSetup.ParamKeys.UserID, context[SettingVariable.LoginUser]);
            conSetup.ConnectionParameters.Add(ConnectionSetup.ParamKeys.Password, context[SettingVariable.LoginPassword]);
            conSetup.ConnectionParameters.Add(ConnectionSetup.ParamKeys.Port, context[SettingVariable.ClientPort]);
            conSetup.ConnectionParameters.Add(ConnectionSetup.ParamKeys.Authenticate, "true");
            conSetup.ConnectionParameters.Add(ConnectionSetup.ParamKeys.WindowsDomain, context[SettingVariable.WindowDomain]);
            conSetup.ConnectionParameters.Add(ConnectionSetup.ParamKeys.IsPrimaryLogin, "true");
            conSetup.ConnectionParameters.Add(ConnectionSetup.ParamKeys.TimeOut, context[SettingVariable.ConnectionTimeout]);

            var label = context[SettingVariable.SecurityLabelName];
            conSetup.ConnectionParameters.Add(ConnectionSetup.ParamKeys.SecurityLabelName, label);
            if (label.ToLower() != "k2")
            {
                conSetup.ConnectionParameters[ConnectionSetup.ParamKeys.Integrated] = "false";
            }

            conn.Open(context[SettingVariable.ServerName], conSetup.ConnectionString);

            return conn;
        }
    protected void Page_Load(object sender, EventArgs e)
    {
        conn = new Connection();

        string connectionstring = ConfigurationManager.ConnectionStrings["connectionstring"].ConnectionString;
        conn.Open(connectionstring);
        //For Demo
        UserIPAddress = GetIPAddress();
        //UserIPAddress = Request.ServerVariables["REMOTE_ADDR"];
        Rs1 = new Recordset();
        sql1 = "Select Station From Station Where IPAddress ='" + UserIPAddress + "'";
        Rs1 = conn.Execute(sql1);
        StationID = Rs1.Fields["Station"].Value;
        UserID = Session["UserID"];
        SecLevel = Session["SecLevel"];
        CarPlate = Request["CarPlate"];
        ProductType = Request["ProductType"];
        Message = "";
        if (Convert.ToString(SecLevel) == "")
        {
            Response.Redirect("Default.aspx");
        }
        Session.Add("SecLevel", SecLevel);
        Session.Add("UserID", UserID);
        Session.Add("StationID", StationID);
    }
Example #4
0
 public void Open()
 {
     if (!Disposed && Connection?.State != ConnectionState.Open)
     {
         Connection?.Open();
     }
 }
        static void Main(string[] args) {
            String broker = args.Length > 0 ? args[0] : "localhost:5672";
            String address = args.Length > 1 ? args[1] : "amq.topic";

            Connection connection = null;
            try {
                connection = new Connection(broker);
                connection.Open();
                Session session = connection.CreateSession();

                Receiver receiver = session.CreateReceiver(address);
                Sender sender = session.CreateSender(address);

                sender.Send(new Message("Hello world!"));

                Message message = new Message();
                message = receiver.Fetch(DurationConstants.SECOND * 1);
                Console.WriteLine("{0}", message.GetContent());
                session.Acknowledge();

                connection.Close();
            } catch (Exception e) {
                Console.WriteLine("Exception {0}.", e);
                if (null != connection)
                    connection.Close();
            }
        }
Example #6
0
        protected void Connect(ITransactionContext transactionContext)
        {
            try
            {
                if (transactionContext?.Transaction != null)
                {
                    Connection = transactionContext.Transaction.Connection;
                    return;
                }

                //create the database connection.
                Connection = DbProviderFactory.CreateConnection() ??
                             throw new FluentDatabaseSessionException(
                                       $"Unable to use the DbProviderFactory {DbProviderFactory.GetType()} to create a valid database connection.");

                //set the connection string on the connection.
                Connection.ConnectionString = ConnectionString;

                //if the connection is not open, which it shouldn't be, then open it
                if (Connection?.State != ConnectionState.Open)
                {
                    Connection?.Open();
                }
            }
            catch (FluentDatabaseSessionException)
            {
                Dispose();
                throw;
            }
            catch (Exception ex)
            {
                Dispose();
                throw new FluentDatabaseSessionException("Error while creating session.", ex, Command?.ToCommandString());
            }
        }
 public void Open()
 {
     //if (!Disposed && Connection?.State == ConnectionState.Closed)
     //{
     //    Connection?.Dispose();
     //}
     if (Disposed && Connection?.State == ConnectionState.Closed)
     {
         if (string.IsNullOrEmpty(Connection?.ConnectionString))
         {
             Connection = CreateInstanceHelper.Resolve <SqlConnection>(ConnectionStringHelper.DefaultConnectionStringName);
         }
         Connection?.Open();
     }
     if (Connection?.State == ConnectionState.Closed)
     {
         if (string.IsNullOrEmpty(Connection?.ConnectionString))
         {
             Connection = CreateInstanceHelper.Resolve <SqlConnection>(ConnectionStringHelper.DefaultConnectionStringName);
         }
         Connection?.Open();
     }
     if (!Disposed && Connection?.State != ConnectionState.Open)
     {
         Connection?.Open();
     }
 }
Example #8
0
        public static void Main(string[] args)
        {
            PrepareCommands();

            m_Connection = new Connection();
            m_Connection.Open();

            //var strokes = MakeStrokeStream(m_Connection);
            //strokes.Subscribe(s => accumulateForceCurve());
            //strokes.Connect();

            Observable.Interval(TimeSpan.FromMilliseconds(500)).Subscribe(_ => Console.WriteLine(accumulateForceCurve()));

            //var Hz10 = Make10HzStream(m_Connection);
            //Hz10.Subscribe(s => Console.WriteLine(string.Format("{0} {1} {2} {3}", s.Item1, s.Item2, s.Item3, s.Item4)));
            //Hz10.Connect();

            //var Hz2 = Make2HzStream(m_Connection);
            //Hz2.Subscribe(s => Console.WriteLine(string.Format("{0} {1} {2} {3}", s.Item6, s.Item1, s.Item2, s.Item3)));
            //Hz2.Connect();

            //var e = MakeEverythingStream(m_Connection);
            //e.Subscribe(s => Console.WriteLine(string.Format("{0}", s.Item6[0])));
            //e.Connect();

            while (true)
            {
            }
            Console.WriteLine("Hello World!");
        }
Example #9
0
        private void btnLoadPI_Click(object sender, EventArgs e)
        {
            try
            {
                Connection cnx = new Connection();
                cnx.Open(ConfigurationManager.AppSettings["K2ServerName"]);
                SourceCode.Workflow.Client.ProcessInstance pi = cnx.OpenProcessInstance(int.Parse(txtProcInstanceId.Text));
                txtFolio.Text = pi.Folio;
                lblStatus.Text = pi.Status1.ToString();
                txtProcessFullName.Text = pi.FullName;
                DataTable dt = new DataTable("Datafields");
                dt.Columns.Add("Name");
                dt.Columns.Add("Value");

                foreach (DataField df in pi.DataFields)
                {
                    dt.Rows.Add(new object[] { df.Name, df.Value });
                }

                displayActivity();

                dgvDatafields.DataSource = dt;
                dgvDatafields.Refresh();
                dgvDatafields.AutoResizeColumn(0);
                dgvDatafields.Columns[0].ReadOnly = true;
                dgvDatafields.AutoResizeColumn(1);

                cnx.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "PI Manager eror");
            }
        }
Example #10
0
 public void Open()
 {
     if (Connection?.State != ConnectionState.Open)
     {
         Connection?.Open();
     }
 }
        //
        // Sample invocation: csharp.example.declare_queues.exe localhost:5672 my-queue
        //
        static int Main(string[] args) {
            string addr = "localhost:5672";
            string queue = "my-queue";

            if (args.Length > 0)
                addr = args[0];
            if (args.Length > 1)
                queue = args[1];

            Connection connection = null;
            try
            {
                connection = new Connection(addr);
                connection.Open();
                Session session = connection.CreateSession();
                String queueName = queue + "; {create: always}";
                Sender sender = session.CreateSender(queueName);
                session.Close();
                connection.Close();
                return 0;
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception {0}.", e);
                if (null != connection)
                    connection.Close();
            }
            return 1;
        }
        public List<SA4Launcher.Models.WorklistItem> LoadWorkList()
        {
            Connection K2Conn = new Connection();
            SCConnectionStringBuilder K2ConnString = new SCConnectionStringBuilder();
            List<SA4Launcher.Models.WorklistItem> _currentWorkList = new List<SA4Launcher.Models.WorklistItem>();

            //Setup Connection String

            K2ConnString.Host = "Sa4DemoK2wAD";
            K2ConnString.Integrated = false;
            K2ConnString.UserID = "SA4Demo\\Tberry";
            K2ConnString.Password = "******";
            K2ConnString.Port = 5252;
            K2ConnString.WindowsDomain = "Sa4Demo";
            K2ConnString.SecurityLabelName = "K2";
            K2ConnString.Authenticate = false;
            K2ConnString.IsPrimaryLogin = true;
            K2Conn.Open("Sa4DemoK2wAD", K2ConnString.ConnectionString.ToString());

            //TODO:  Need to add try loop with true false return
            Worklist K2WorkList = K2Conn.OpenWorklist();
            List<SA4Launcher.Models.Action> CurrentActions = new List<SA4Launcher.Models.Action>();

            if (K2WorkList != null)
            {
                _currentWorkList.Clear();
                foreach (SourceCode.Workflow.Client.WorklistItem K2worklistitem in K2WorkList)
                {
                    //Build Actions First
                    CurrentActions.Clear();
                    foreach (SourceCode.Workflow.Client.Action K2action in K2worklistitem.Actions)
                    {
                        CurrentActions.Add(new SA4Launcher.Models.Action
                        {
                            Name = K2action.Name,
                            Batchable = K2action.Batchable
                        });
                    }

                    //Load worklist items into model
                    _currentWorkList.Add(new SA4Launcher.Models.WorklistItem
                    {
                        ID = K2worklistitem.ID,
                        serialno = K2worklistitem.SerialNumber,
                        Name = K2worklistitem.ProcessInstance.Name,
                        UserName = K2worklistitem.AllocatedUser,
                        Folio = K2worklistitem.ProcessInstance.Folio,
                        StartDate = K2worklistitem.ProcessInstance.StartDate,
                        Status = K2worklistitem.Status.ToString(),
                        ViewFlow = K2worklistitem.ProcessInstance.ViewFlow,
                        Data = K2worklistitem.Data,
                        Priority = K2worklistitem.ProcessInstance.Priority,
                        Actions = CurrentActions.ToList()
                    });
                }
            }
            K2Conn.Close();
            return (_currentWorkList);
        }
Example #13
0
 private async Task ResetPrinterLanguageToLinePrintAsync(Connection connection)
 {
     await Task.Factory.StartNew(() => {
         try {
             connection?.Open();
             SGD.SET(DeviceLanguagesSgd, "line_print", connection);
         } catch (ConnectionException) { }
     });
 }
 protected void Connect(string connectionString)
 {
     if (Connection != null)
     {
         return;
     }
     Connection = CreateInstanceHelper.Resolve <TConnection>(connectionString);
     Connection?.Open();
 }
        //
        // Sample invocation: csharp.example.drain.exe --broker localhost:5672 --timeout 30 my-queue
        //
        static int Main(string[] args) {
            Options options = new Options(args);

            Connection connection = null;
            try
            {
                connection = new Connection(options.Url, options.ConnectionOptions);
                connection.Open();
                Session session = connection.CreateSession();
                Receiver receiver = session.CreateReceiver(options.Address);
                Duration timeout = options.Forever ? 
                                   DurationConstants.FORVER : 
                                   DurationConstants.SECOND * options.Timeout;
                Message message = new Message();

                while (receiver.Fetch(ref message, timeout))
                {
                    Dictionary<string, object> properties = new Dictionary<string, object>();
                    properties = message.Properties;
                    Console.Write("Message(properties={0}, content='", 
                                  message.MapAsString(properties));

                    if ("amqp/map" == message.ContentType)
                    {
                        Dictionary<string, object> content = new Dictionary<string, object>();
                        message.GetContent(content);
                        Console.Write(message.MapAsString(content));
                    }
                    else if ("amqp/list" == message.ContentType)
                    {
                        Collection<object> content = new Collection<object>();
                        message.GetContent(content);
                        Console.Write(message.ListAsString(content));
                    }
                    else
                    {
                        Console.Write(message.GetContent());
                    }
                    Console.WriteLine("')");
                    session.Acknowledge();
                }
                receiver.Close();
                session.Close();
                connection.Close();
                return 0;
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception {0}.", e);
                if (null != connection)
                    connection.Close();
            }
            return 1;
        }
        static int Main(string[] args) {
            Options options = new Options(args);

            Connection connection = null;
            try
            {
                connection = new Connection(options.Url, options.ConnectionOptions);
                connection.Open();
                Session session = connection.CreateSession();
                Sender sender = session.CreateSender(options.Address);
                Message message;
                if (options.Entries.Count > 0)
                {
                    Dictionary<string, object> content = new Dictionary<string, object>();
                    SetEntries(options.Entries, content);
                    message = new Message(content);
                }
                else
                {
                    message = new Message(options.Content);
                    message.ContentType = "text/plain";
                }
                Address replyToAddr = new Address(options.ReplyTo);

                Stopwatch stopwatch = new Stopwatch();
                TimeSpan timespan = new TimeSpan(0,0,options.Timeout);
                stopwatch.Start();
                for (int count = 0;
                    (0 == options.Count || count < options.Count) &&
                    (0 == options.Timeout || stopwatch.Elapsed <= timespan);
                    count++) 
                {
                    if ("" != options.ReplyTo) message.ReplyTo = replyToAddr;
                    string id = options.Id ;
                    if ("" == id) {
                        Guid g = Guid.NewGuid();
                        id = g.ToString();
                    }
                    string spoutid = id + ":" + count;
                    message.SetProperty("spout-id", spoutid);
                    sender.Send(message);
                }
                session.Sync();
                connection.Close();
                return 0;
            } catch (Exception e) {
                Console.WriteLine("Exception {0}.", e);
                if (null != connection)
                    connection.Close();
            }
            return 1;
        }
    void Start()
    {
        // Create the SignalR connection
        signalRConnection = new Connection(URI);

        // set event handlers
        signalRConnection.OnNonHubMessage += signalRConnection_OnNonHubMessage;
        signalRConnection.OnStateChanged += signalRConnection_OnStateChanged;
        signalRConnection.OnError += signalRConnection_OnError;

        // Start connecting to the server
        signalRConnection.Open();
    }
        // csharp.map.receiver example
        //
        // Send an amqp/map message to amqp:tcp:localhost:5672 amq.direct/map_example
        // The map message 
        //
        static int Main(string[] args)
        {
            string url = "amqp:tcp:localhost:5672";
            string address = "message_queue; {create: always}";
            string connectionOptions = "";

            if (args.Length > 0)
                url = args[0];
            if (args.Length > 1)
                address = args[1];
            if (args.Length > 2)
                connectionOptions = args[2];

            //
            // Create and open an AMQP connection to the broker URL
            //
            Connection connection = new Connection(url);
            connection.Open();

            //
            // Create a session and a receiver fir the direct exchange using the
            // routing key "map_example".
            //
            Session session = connection.CreateSession();
            Receiver receiver = session.CreateReceiver(address);

            //
            // Fetch the message from the broker
            //
            Message message = receiver.Fetch(DurationConstants.MINUTE);

            //
            // Extract the structured content from the message.
            //
            Dictionary<string, object> content = new Dictionary<string, object>();
            message.GetContent(content);
            Console.WriteLine("{0}", message.AsString(content));

            //
            // Acknowledge the receipt of all received messages.
            //
            session.Acknowledge();

            //
            // Close the receiver and the connection.
            //
            receiver.Close();
            connection.Close();
            return 0;
        }
    void Start()
    {
        // Connect to the StatusHub hub
        signalRConnection = new Connection(URI, "StatusHub");

        // General events
        signalRConnection.OnNonHubMessage += signalRConnection_OnNonHubMessage;
        signalRConnection.OnError += signalRConnection_OnError;
        signalRConnection.OnStateChanged += signalRConnection_OnStateChanged;

        // Set up a callback for Hub events
        signalRConnection["StatusHub"].OnMethodCall += statusHub_OnMethodCall;

        // Connect to the server
        signalRConnection.Open();
    }
        static int Main(string[] args) {
            String url = "amqp:tcp:127.0.0.1:5672";
            String connectionOptions = "";

            if (args.Length > 0)
                url = args[0];
            if (args.Length > 1)
                connectionOptions = args[1];

            Connection connection = new Connection(url, connectionOptions);
            try
            {
                connection.Open();

                Session session = connection.CreateSession();

                Sender sender = session.CreateSender("service_queue");

                Address responseQueue = new Address("#response-queue; {create:always, delete:always}");
                Receiver receiver = session.CreateReceiver(responseQueue);

                String[] s = new String[] {
                    "Twas brillig, and the slithy toves",
                    "Did gire and gymble in the wabe.",
                    "All mimsy were the borogroves,",
                    "And the mome raths outgrabe."
                };

                Message request = new Message("");
                request.ReplyTo = responseQueue;

                for (int i = 0; i < s.Length; i++) {
                    request.SetContent(s[i]);
                    sender.Send(request);
                    Message response = receiver.Fetch();
                    Console.WriteLine("{0} -> {1}", request.GetContent(), response.GetContent());
                }
                connection.Close();
                return 0;
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception {0}.", e);
                connection.Close();
            }
            return 1;
        }
        public OdbcCommandExecutor(string sql, int timeout = 3)
        {
#if !KEEPSQLOPEN
            if (Connection.State == ConnectionState.Closed)
            {
                Connection?.Open();
            }
            else
            {
                throw new Exception("Какого хуя подключение открыто, используй using!");
            }
#endif
            Command = new OdbcCommand(sql, Connection)
            {
                CommandTimeout = timeout
            };
        }
        // Direct sender example
        //
        // Send 10 messages from localhost:5672, amq.direct/key
        // Messages are assumed to be printable strings.
        //
        static int Main(string[] args)
        {
            String host = "localhost:5672";
            String addr = "amq.direct/key";
            Int32 nMsg = 10;

            if (args.Length > 0)
                host = args[0];
            if (args.Length > 1)
                addr = args[1];
            if (args.Length > 2)
                nMsg = Convert.ToInt32(args[2]);

            Console.WriteLine("csharp.direct.sender");
            Console.WriteLine("host : {0}", host);
            Console.WriteLine("addr : {0}", addr);
            Console.WriteLine("nMsg : {0}", nMsg);
            Console.WriteLine();

            Connection connection = null;
            try
            {
                connection = new Connection(host);
                connection.Open();

                if (!connection.IsOpen) {
                    Console.WriteLine("Failed to open connection to host : {0}", host);
                } else {
                    Session session = connection.CreateSession();
                    Sender sender = session.CreateSender(addr);
                    for (int i = 0; i < nMsg; i++) {
                        Message message = new Message(String.Format("Test Message {0}", i));
                        sender.Send(message);
                    }
                    session.Sync();
                    connection.Close();
                    return 0;
                }
            } catch (Exception e) {
                Console.WriteLine("Exception {0}.", e);
                if (null != connection)
                    connection.Close();
            }
            return 1;
        }
        // Direct receiver example
        //
        // Receive 10 messages from localhost:5672, amq.direct/key
        // Messages are assumed to be printable strings.
        //
        static int Main(string[] args)
        {
            String host = "localhost:5672";
            String addr = "amq.direct/key";
            Int32 nMsg = 10;

            if (args.Length > 0)
                host = args[0];
            if (args.Length > 1)
                addr = args[1];
            if (args.Length > 2)
                nMsg = Convert.ToInt32(args[2]);

            Console.WriteLine("csharp.direct.receiver");
            Console.WriteLine("host : {0}", host);
            Console.WriteLine("addr : {0}", addr);
            Console.WriteLine("nMsg : {0}", nMsg);
            Console.WriteLine();

            Connection connection = null;
            try
            {
                connection = new Connection(host);
                connection.Open();
                if (!connection.IsOpen) {
                    Console.WriteLine("Failed to open connection to host : {0}", host);
                } else {
                    Session session = connection.CreateSession();
                    Receiver receiver = session.CreateReceiver(addr);
                    Message message = new Message("");
                    for (int i = 0; i < nMsg; i++) {
                        Message msg2 = receiver.Fetch(DurationConstants.FORVER);
                        Console.WriteLine("Rcvd msg {0} : {1}", i, msg2.GetContent());
                    }
                    connection.Close();
                    return 0;
                }
            } catch (Exception e) {
                Console.WriteLine("Exception {0}.", e);
                if (null != connection)
                    connection.Close();
            }
            return 1;
        }
        private async void GetSettingsButton_Clicked(object sender, EventArgs eventArgs)
        {
            ClearSettings();
            SetInputEnabled(false);

            Connection connection       = null;
            bool       linePrintEnabled = false;

            try {
                await Task.Factory.StartNew(() => {
                    connection = CreateConnection();
                    connection.Open();

                    string originalPrinterLanguage = SGD.GET(DeviceLanguagesSgd, connection);
                    linePrintEnabled = "line_print".Equals(originalPrinterLanguage, StringComparison.OrdinalIgnoreCase);

                    if (linePrintEnabled)
                    {
                        SGD.SET(DeviceLanguagesSgd, "zpl", connection);
                    }

                    UpdateSettingsTable(connection, originalPrinterLanguage);
                });
            } catch (Exception e) {
                await DisplayAlert("Error", e.Message, "OK");
            } finally {
                if (linePrintEnabled)
                {
                    await Task.Factory.StartNew(() => {
                        try {
                            connection?.Open();
                            SGD.SET(DeviceLanguagesSgd, "line_print", connection);
                        } catch (ConnectionException) { }
                    });
                }

                try {
                    connection?.Close();
                } catch (ConnectionException) { }

                SetInputEnabled(true);
            }
        }
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            conn = new Connection();
           string connectionstring = ConfigurationManager.ConnectionStrings["connectionstring"].ConnectionString;
            conn.Open(connectionstring); 
            UserID = (Request["UserID"]).Trim();
            Level = (Request["SecLevel"]).Trim();
            StationID = (Request["StationID"]).Trim();
            UserID = (Request["UserID"]).TrimEnd();
            SDay = Request["SDay"];
            SMonth = Request["SMonth"];
            SYear = Request["SYear"];
            NDay = Request["NDay"];
            NMonth = Request["NMonth"];
            NYear = Request["NYear"];
            // Search_Date = Strings.FormatDateTime(new DateTime(Convert.ToInt32(SYear), Convert.ToInt32(SMonth), Convert.ToInt32(SDay)), (DateFormat)2);
            //Search_NDate = Strings.FormatDateTime(new DateTime(Convert.ToInt32(NYear), Convert.ToInt32(NMonth), Convert.ToInt32(NDay)), (DateFormat)2);

            Search_Date = SDay + "/" + SMonth + "/" + SYear;
            Search_NDate = NDay + "/" + NMonth + "/" + NYear;
            fsql = "select * from MasterCoupon where RequestedID = " + StationID +
                " and  Present_Date >=   Convert(datetime, '" + Search_Date + "', 105) " +
                " and  Present_Date < DATEADD(dd,DATEDIFF(dd,0, Convert(datetime, '" + Search_NDate + "', 105)),0) + 1 " +
                " order by id desc";
            //response.write fsql
            //response.end
            RS1 = conn.Execute(fsql);
           
          
            //Today = Strings.FormatDateTime(DateTime.Now, (DateFormat)2);
            Today = DateTime.Now.ToString("dd-MM-yyyy");
            Response.ContentType = "application/pdf";

            Response.AddHeader("content-disposition", "attachment;filename=§¨é¬ö¿ý(" + Today + ").pdf");       
          //  Write_CSV_From_Recordset(RS1);
            ExportToPDF(RS1, true, StationID);
        }
        catch (Exception ex)
        { 
        }
    }
        public Worklist GetWorklistItems(String searchTerm, Int32 skip, Int32 take, Dictionary<WCField, WCSortOrder> sorts, String impersonateUser)
        {
            using (var k2Connection = new Connection())
            {
                ConnectionSetup k2Setup = new ConnectionSetup();
                k2Setup.ConnectionString = Properties.Settings.Default.WorkflowServerConnectionString;

                k2Connection.Open(k2Setup);

                if (!String.IsNullOrEmpty(impersonateUser))
                    k2Connection.ImpersonateUser("K2:" + impersonateUser);

                var workCriteria = new WorklistCriteria { NoData = true, Platform = "ASP" };                                                
                                
                if (!string.IsNullOrEmpty(searchTerm))
                {
                    String searchTermFormat = String.Format("%{0}%", searchTerm);
                    //String searchTermFormat = String.Format("% / % / % / % / %{0}%", searchTerm);
                    workCriteria.AddFilterField(WCLogical.StartBracket, WCField.None, WCCompare.Equal, null);           //  (
                    workCriteria.AddFilterField(WCField.ActivityName, WCCompare.Like, searchTermFormat);                //  ...
                    workCriteria.AddFilterField(WCLogical.Or, WCField.EventName, WCCompare.Like, searchTermFormat);     //  OR ...
                    workCriteria.AddFilterField(WCLogical.Or, WCField.ProcessFolio, WCCompare.Like, searchTermFormat);  //  OR ...
                    workCriteria.AddFilterField(WCLogical.EndBracket, WCField.None, WCCompare.Equal, null);             //  )
                    //workCriteria.AddFilterField(WCField.ProcessFolio, WCCompare.Like, searchTermFormat);
                }

                //  No AND required - seems like bug - this bit gets put in a different bit of the query K2 creates.
                //  Hide allocated items like the SharePoint K2 worlist does by default.
                workCriteria.AddFilterField(WCField.WorklistItemStatus, WCCompare.NotEqual, WorklistStatus.Allocated);                 

                workCriteria.StartIndex = skip;
                workCriteria.Count = take;                
                
                foreach (KeyValuePair<WCField,WCSortOrder> sort in sorts)
                {
                    workCriteria.AddSortField(sort.Key, sort.Value);                                        
                }

                Worklist k2Worklist = k2Connection.OpenWorklist(workCriteria);      

                return k2Worklist;
            }
        }
Example #27
0
        /// <summary>
        /// Begins a <see cref="DbTransaction"/> for this database session.  If a <paramref name="logger"/>
        /// is given, the opening of the <see cref="DbTransaction"/> will be logged.
        /// </summary>
        /// <param name="logger"></param>
        /// <returns></returns>
        /// <exception cref="FluentDatabaseSessionException">This exception will be thrown for the following reasons:
        /// 1. The connection associated with this database session is null
        /// 2. If after a call to open the connection, on a connection that is not currently open, the connection is still not open</exception>
        public ITransactionContext CreateTransaction(Action <string> logger = null)
        {
            try
            {
                Connect(null);

                if (Connection == null)
                {
                    throw new FluentDatabaseSessionException("Connection is not valid");
                }

                if (Connection.State != ConnectionState.Open)
                {
                    Connection?.Open();
                }

                if (Connection.State != ConnectionState.Open)
                {
                    throw new FluentDatabaseSessionException("Unable to open connection successfully");
                }

                var transaction = Connection.BeginTransaction();

                var message = $"Transaction: {transaction.GetHashCode()} - Begin";

                var transactionContext = new TransactionContext(transaction);

                logger?.Invoke(message);

                return(transactionContext);
            }
            catch (FluentDatabaseSessionException)
            {
                Dispose();
                throw;
            }
            catch (Exception ex)
            {
                Dispose();
                throw new FluentDatabaseSessionException("Error while beginning transaction.", ex);
            }
        }
Example #28
0
        public void ConnectAndReceive()
        {
            try
            {
                _sessionReceiver = new TradeConfirmationReceiver();
                /*
                   * Step 1: Preparing the connection and session
                   */
                _connection = new Connection(_brokerAddress);
                _connection.SetOption("reconnect", true);
                _connection.SetOption("reconnect_limit", 2);
                _connection.SetOption("reconnect_urls", _failBrokerAddress);

                //must set the username, a little different with Eurex's Demo code
                //the username is case sensitive
                //be carful, the .cert's frendly is empty in LCMLO_LIQSPALBB.crt
                _connection.SetOption("username", _memberName);
                _connection.SetOption("transport", "ssl");
                _connection.SetOption("sasl_mechanisms", "EXTERNAL");
                _connection.SetOption("heartbeat", 60);//unit:seconds

                _connection.Open();

                _session = _connection.CreateSession();
                /*
                 * Step 2: Create callback server and implicitly start it
                 */
                // The callback server is running and executing callbacks on a separate thread.
                _callbackServer = new CallbackServer(_session, _sessionReceiver);
                /*
                 * Step 3: Creating message consumer
                 */
                _receiver = _session.CreateReceiver(_broadcastAddress);
                _receiver.Capacity = 100;
            }
            catch (QpidException ex)
            {
                _Log.Error("Make connection to AMQP broker failed!", ex);
                throw;
            }
        }
    void Start()
    {
        // Create the SignalR connection, and pass the hubs that we want to connect to
        signalRConnection = new Connection(URI, new BaseHub("noauthhub", "Messages"),
                                                new BaseHub("invokeauthhub", "Messages Invoked By Admin or Invoker"),
                                                new BaseHub("authhub", "Messages Requiring Authentication to Send or Receive"),
                                                new BaseHub("inheritauthhub", "Messages Requiring Authentication to Send or Receive Because of Inheritance"),
                                                new BaseHub("incomingauthhub", "Messages Requiring Authentication to Send"),
                                                new BaseHub("adminauthhub", "Messages Requiring Admin Membership to Send or Receive"),                            
                                                new BaseHub("userandroleauthhub", "Messages Requiring Name to be \"User\" and Role to be \"Admin\" to Send or Receive"));
        
        // Set the authenticator if we have valid fields
        if (!string.IsNullOrEmpty(userName) && !string.IsNullOrEmpty(role))
            signalRConnection.AuthenticationProvider = new HeaderAuthenticator(userName, role);

        // Set up event handler
        signalRConnection.OnConnected += signalRConnection_OnConnected;

        // Start to connect to the server.
        signalRConnection.Open();
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        conn = new Connection();
      
        string connectionstring = ConfigurationManager.ConnectionStrings["connectionstring"].ConnectionString;
        conn.Open(connectionstring); 
        
        UserIPAddress = GetIPAddress();
        //For Demo            
        //UserIPAddress = "192.168.1.12";
	    //UserIPAddress = Request.ServerVariables["REMOTE_ADDR"];
        Rs1 = new Recordset();
        sql1 = "Select Station , LoginUser  From Station Where IPAddress ='" + UserIPAddress + "'";
        Rs1 = conn.Execute(sql1);
        StationID = Rs1.Fields["Station"].Value;
        UserID = Rs1.Fields["LoginUser"].Value;     
        CarPlate = Request["CarPlate"];
        ProductType = Request["ProductType"];
        Message = "";     
        
    }
Example #31
0
    void Start()
    {
#if !BESTHTTP_DISABLE_COOKIES
        // Set a "user" cookie if we previously used the 'Enter Name' button.
        // The server will set this username to the new connection.
        if (PlayerPrefs.HasKey("userName"))
            CookieJar.Set(URI, new Cookie("user", PlayerPrefs.GetString("userName")));
#endif

        signalRConnection = new Connection(URI);

        // to serialize the Message class, set a more advanced json encoder
        signalRConnection.JsonEncoder = new BestHTTP.SignalR.JsonEncoders.LitJsonEncoder();

        // set up event handlers
        signalRConnection.OnStateChanged += signalRConnection_OnStateChanged;
        signalRConnection.OnNonHubMessage += signalRConnection_OnGeneralMessage;

        // Start to connect to the server.
        signalRConnection.Open();
    }
Example #32
0
        static int Main(string[] args)
        {
            string url = "amqp:tcp:127.0.0.1:5672";
            string connectionOptions = "";

            if (args.Length > 0)
                url = args[0];
            // address args[1] is not used in this example
            if (args.Length > 2)
                connectionOptions = args[2];

            try {
                Connection connection = new Connection(url, connectionOptions);
                connection.Open();
                Session session = connection.CreateSession();
                Receiver receiver = session.CreateReceiver("service_queue; {create: always}");

                while (true) {
                    Message request = receiver.Fetch();
                    Address address = request.ReplyTo;

                    if (null != address) {
                        Sender sender = session.CreateSender(address);
                        String s = request.GetContent();
                        Message response = new Message(s.ToUpper());
                        sender.Send(response);
                        Console.WriteLine("Processed request: {0} -> {1}", request.GetContent(), response.GetContent());
                        session.Acknowledge();
                    } else {
                        Console.WriteLine("Error: no reply address specified for request: {0}", request.GetContent());
                        session.Reject(request);
                    }
                }
                // connection.Close();  // unreachable in this example
            } catch (Exception e) {
                Console.WriteLine("Exception {0}.", e);
            }
            return 1;
        }
Example #33
0
        /// <summary>
        /// 调用k2的dll,生成流程
        /// <param name="dataFields">开启流程所需数据</param>
        /// <param name="processName">流程名称</param>
        /// </summary>
        public static int StartProcess(string processName, Dictionary<string, string> dataFields, string objectId, string folio, string userName)
        {
            int processInstId = 0;
            Connection k2Connection = new Connection();

            try
            {
                k2Connection.Open(ConfigurationBase.Web.K2Server, ConfigurationBase.Web.K2LoginString);
                k2Connection.ImpersonateUser(userName);

                //创建实例
                ProcessInstance processInst = k2Connection.CreateProcessInstance(processName);
                processInstId = processInst.ID;

                if (!string.IsNullOrEmpty(folio))
                {
                    processInst.Folio = folio;
                }
                #region 赋值datafields
                foreach (string key in dataFields.Keys)
                {
                    if (processInst.DataFields[key] != null)
                    {
                        processInst.DataFields[key].Value = dataFields[key];
                    }
                }
                #endregion
            }
            finally
            {
                if (k2Connection != null)
                {
                    k2Connection.Close();
                }
            }

            return processInstId;
        }
Example #34
0
        public bool IsDriverAvailableForUpdate(Vehicle vehicle)
        {
            Query = "SELECT * FROM Vehicle WHERE DriverId = @id And Id <> @vid";

            Command = new SqlCommand(Query, Connection);
            Connection.Open();
            Command.Parameters.Clear();
            Command.Parameters.Add("id", SqlDbType.Int);
            Command.Parameters["id"].Value = vehicle.DriverId;
            Command.Parameters.Add("vid", SqlDbType.Int);
            Command.Parameters["vid"].Value = vehicle.Id;
            Reader = Command.ExecuteReader();

            bool hasRows = false;

            if (Reader.Read())
            {
                hasRows = true;
            }
            Reader.Close();
            Connection.Close();
            return(hasRows);
        }
        public void OnGet()
        {
            var connection = Connection.Open();
            var list       = UsersDAO.GetMyDiscussions(login.LoginSession, connection);

            discussions = new List <Discussion>();
            if (list != null)
            {
                var str = list.Aggregate("", (current, e) => current + ($@"'{e}'" + ","));
                str = str.Remove(str.Length - 1);
                var reader =
                    Connection.GetDataFromDb(connection, $@"SELECT * FROM FORUM WHERE discussion_id in ({str})");
                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        discussions.Add(ForumDAO.MadeNewDiscussionObject(reader, connection));
                    }
                }
            }

            connection.Close();
        }
Example #36
0
        public Vehicle GetVehicleIdByNo(Vehicle vehicle)
        {
            Query = "SELECT * FROM Vehicle WHERE VehicleNo= @vehicleNo ";

            Command = new SqlCommand(Query, Connection);
            Connection.Open();
            Command.Parameters.Clear();
            Command.Parameters.Add("vehicleNo", SqlDbType.VarChar);
            Command.Parameters["vehicleNo"].Value = vehicle.VehicleNo;
            Reader = Command.ExecuteReader();
            Vehicle aVehicle = null;

            if (Reader.Read())
            {
                aVehicle = new Vehicle()
                {
                    Id = (int)Reader["Id"],
                };
            }
            Reader.Close();
            Connection.Close();
            return(aVehicle);
        }
Example #37
0
        public override bool Exists(string template, params object[] args)
        {
            if (Connection.State != ConnectionState.Open)
            {
                Connection.Open();
            }

            using (var command = factory.CreateCommand(String.Format(template, args), Connection))
            {
                command.CommandTimeout = Options.Timeout;
                using (var reader = command.ExecuteReader())
                {
                    try
                    {
                        return(reader.Read());
                    }
                    catch
                    {
                        return(false);
                    }
                }
            }
        }
        //public List<ViewClassSheduleViewModel> showClassDetails(Department aDepartment)
        public List <ViewClassSheduleViewModel> showClassDetails(int DeptId)
        {
            string query = "SELECT CourseId,CourseCode,CourseName FROM Course WHERE DeptId=@DeptId";

            Command = new SqlCommand(query, Connection);
            Command.Parameters.AddWithValue("@DeptId", DeptId);
            Connection.Open();
            List <ViewClassSheduleViewModel> viewClassShedule = new List <ViewClassSheduleViewModel>();

            Reader = Command.ExecuteReader();
            while (Reader.Read())
            {
                ViewClassSheduleViewModel aviewClassShedule = new ViewClassSheduleViewModel();
                aviewClassShedule.CourseId   = Convert.ToInt32(Reader["CourseId"]);
                aviewClassShedule.CourseCode = Reader["CourseCode"].ToString();
                aviewClassShedule.CourseName = Reader["CourseName"].ToString();
                viewClassShedule.Add(aviewClassShedule);
            }
            Reader.Close();
            Connection.Close();

            return(CourseGroupByClassAndRoom(viewClassShedule));
        }
Example #39
0
        public List <ExpenseModel> PrcGetExpenseList(string date)
        {
            List <ExpenseModel> expenseList = new List <ExpenseModel>();

            Query   = "Exec prcGetExpenseDetails '" + date + "'";
            Command = new SqlCommand(Query, Connection);
            Connection.Open();
            Reader = Command.ExecuteReader();
            while (Reader.Read())
            {
                ExpenseModel bExpenseModel = new ExpenseModel();
                bExpenseModel.ExpenseId   = Convert.ToInt32(Reader["Id"]);
                bExpenseModel.ExpenseType = Reader["ExpenseType"].ToString();
                bExpenseModel.ExpenseName = Reader["ExpenseName"].ToString();
                bExpenseModel.Amount      = Convert.ToInt32(Reader["Amount"]);
                bExpenseModel.DtExpense   = Reader["DtExpense"].ToString();
                bExpenseModel.Comment     = Reader["Comments"].ToString();
                expenseList.Add(bExpenseModel);
            }
            Reader.Close();
            Connection.Close();
            return(expenseList);
        }
Example #40
0
        public int AddRoute(RouteVM route)
        {
            Query =
                "INSERT INTO Route(Code,StartPlace,EndPlace) VALUES(@code, @startPlace, @endPlace)";

            Command = new SqlCommand(Query, Connection);
            Command.Parameters.Clear();
            Command.Parameters.Add("code", SqlDbType.VarChar);
            Command.Parameters["code"].Value = route.RouteCode;

            Command.Parameters.Add("startPlace", SqlDbType.VarChar);
            Command.Parameters["startPlace"].Value = route.StartPlace;

            Command.Parameters.Add("endPlace", SqlDbType.VarChar);
            Command.Parameters["endPlace"].Value = route.EndPlace;

            Connection.Open();

            int rowAffected = Command.ExecuteNonQuery();

            Connection.Close();
            return(rowAffected);
        }
        public List <EnrollStudentInCourse> GetEnrollStudentCourses()
        {
            Query   = "SELECT ec.Id,ec.CourseId,ec.StudentId,c.Name FROM EnrollCourse_tb AS ec LEFT JOIN Course_tb AS c on ec.CourseId = c.Id";
            Command = new SqlCommand(Query, Connection);
            Connection.Open();
            Reader = Command.ExecuteReader();
            List <EnrollStudentInCourse> enrollStudentCourses = new List <EnrollStudentInCourse>();

            while (Reader.Read())
            {
                EnrollStudentInCourse enrollStudentCourse = new EnrollStudentInCourse
                {
                    Id         = (int)Reader["Id"],
                    CourseName = Reader["Name"].ToString(),
                    CourseId   = (int)Reader["CourseId"],
                    StudentId  = (int)Reader["StudentId"],
                };
                enrollStudentCourses.Add(enrollStudentCourse);
            }
            Reader.Close();
            Connection.Close();
            return(enrollStudentCourses);
        }
        protected override void Process(string sql)
        {
            Announcer.Sql(sql);

            if (Options.PreviewOnly || string.IsNullOrEmpty(sql))
            {
                return;
            }

            if (Connection.State != ConnectionState.Open)
            {
                Connection.Open();
            }

            if (sql.Contains("GO"))
            {
                ExecuteBatchNonQuery(sql);
            }
            else
            {
                ExecuteNonQuery(sql);
            }
        }
        public bool IsCourseExists(StudentMustafa student)
        {
            Query   = "SELECT * FROM StudentCourse Where StudentRegNo = @str AND CourseId = @courseId ";
            Command = new SqlCommand(Query, Connection);
            Connection.Open();
            Command.Parameters.Clear();
            Command.Parameters.Add("str", SqlDbType.VarChar);
            Command.Parameters["str"].Value = student.RegNo;
            Command.Parameters.Add("courseId", SqlDbType.Int);
            Command.Parameters["courseId"].Value = student.CourseId;
            Reader = Command.ExecuteReader();


            bool isExist = false;

            if (Reader.HasRows)
            {
                isExist = true;
            }
            Reader.Close();
            Connection.Close();
            return(isExist);
        }
        public StudentMustafa GetStudentDetailsWithRegistrationNo(StudentMustafa student)
        {
            Query   = "SELECT s.Name, s.Email, s.DepartmentId,s.RegistrationNo,d.Code from Student s INNER JOIN Department d on d.id = s.DepartmentId where s.id = @id";
            Command = new SqlCommand(Query, Connection);
            Connection.Open();
            Command.Parameters.Clear();
            Command.Parameters.Add("id", SqlDbType.Int);
            Command.Parameters["id"].Value = student.Id;
            Reader = Command.ExecuteReader();
            StudentMustafa studentInfo = new StudentMustafa();

            while (Reader.Read())
            {
                studentInfo.Name         = Reader["Name"].ToString();
                studentInfo.Email        = Reader["Email"].ToString();
                studentInfo.Code         = Reader["Code"].ToString();
                studentInfo.RegNo        = Reader["RegistrationNo"].ToString();
                studentInfo.DepartmentId = Convert.ToInt32(Reader["DepartmentId"].ToString());
            }
            Reader.Close();
            Connection.Close();
            return(studentInfo);
        }
        public ResultVM GetStudentByRegNo(int id)
        {
            Query   = "SELECT * FROM Student WHERE Id = @id";
            Command = new SqlCommand(Query, Connection);
            Command.Parameters.Clear();
            Command.Parameters.Add("id", SqlDbType.Int);
            Command.Parameters["id"].Value = id;
            Connection.Open();
            SqlDataReader reader  = Command.ExecuteReader();
            ResultVM      student = null;

            while (reader.Read())
            {
                student                = new ResultVM();
                student.Id             = (int)reader["Id"];
                student.StudentName    = reader["Name"].ToString();
                student.Email          = reader["Email"].ToString();
                student.DepartmentName = reader["Name"].ToString();
            }
            reader.Close();
            Connection.Close();
            return(student);
        }
Example #46
0
        public Vehicle GetVehicleId(int id)
        {
            Query = "SELECT Id FROM Vehicle WHERE DriverId = @id";

            Command = new SqlCommand(Query, Connection);
            Connection.Open();
            Command.Parameters.Clear();
            Command.Parameters.Add("id", SqlDbType.Int);
            Command.Parameters["id"].Value = id;
            Reader = Command.ExecuteReader();
            Vehicle vehicle = null;

            if (Reader.Read())
            {
                vehicle = new Vehicle()
                {
                    Id = (int)Reader["Id"],
                };
            }
            Reader.Close();
            Connection.Close();
            return(vehicle);
        }
Example #47
0
        public List <RouteVM> GetAllRoutes()
        {
            Query = "SELECT * FROM Route";

            Command = new SqlCommand(Query, Connection);
            Connection.Open();
            Reader = Command.ExecuteReader();
            List <RouteVM> routes = new List <RouteVM>();

            while (Reader.Read())
            {
                RouteVM route = new RouteVM()
                {
                    RouteCode  = Reader["Code"].ToString(),
                    StartPlace = Reader["StartPlace"].ToString(),
                    EndPlace   = Reader["EndPlace"].ToString()
                };
                routes.Add(route);
            }
            Reader.Close();
            Connection.Close();
            return(routes);
        }
Example #48
0
 public int UpdateBarcode(Product product)
 {
     try
     {
         Query = "UPDATE tbl_Product SET Barcode=@Barcode WHERE ProductId=@ProductId";
         Command.CommandText = Query;
         Command.Parameters.Clear();
         Command.Parameters.Add("Barcode", SqlDbType.VarBinary);
         Command.Parameters["Barcode"].Value = product.Barcode;
         Command.Parameters.Add("ProductId", SqlDbType.Int);
         Command.Parameters["ProductId"].Value = product.Id;
         Connection.Open();
         int rowAffected = Command.ExecuteNonQuery();
         return(rowAffected);
     }
     finally
     {
         if (Connection != null && Connection.State != ConnectionState.Closed)
         {
             Connection.Close();
         }
     }
 }
        public Company Get(int id)
        {
            Company company = new Company();

            Query = "select * from Company where Id = '" + id + "'";

            Command = new SqlCommand(Query, Connection);

            Connection.Open();

            Reader = Command.ExecuteReader();

            while (Reader.Read())
            {
                company.Id   = Convert.ToInt32(Reader["Id"]);
                company.Name = Reader["Name"].ToString();
            }

            Reader.Close();
            Connection.Close();

            return(company);
        }
Example #50
0
        public bool IsVehicleNoExistsForUpdate(Vehicle vehicle)
        {
            Query = "SELECT * FROM Vehicle WHERE VehicleNo = @vehicleNo And Id <> @id";

            Command = new SqlCommand(Query, Connection);

            Command.Parameters.Clear();
            Command.Parameters.Add("vehicleNo", SqlDbType.VarChar);
            Command.Parameters["vehicleNo"].Value = vehicle.VehicleNo;
            Command.Parameters.Add("id", SqlDbType.Int);
            Command.Parameters["id"].Value = vehicle.Id;
            Connection.Open();
            Reader = Command.ExecuteReader();
            bool hasRow = false;

            if (Reader.HasRows)
            {
                hasRow = true;
            }
            Reader.Close();
            Connection.Close();
            return(hasRow);
        }
Example #51
0
        public int Save(ReceptionistModel receptionist)
        {
            query = "INSERT INTO ReceptionistTable " +
                    "VALUES(@firstName,@lastName,@contactNo,@address," +
                    "@qalification,@Age,@BloodGroup ) ";

            Command = new SqlCommand(query, Connection);

            Command.Parameters.AddWithValue("@firstName", receptionist.FirstName);
            Command.Parameters.AddWithValue("@lastName", receptionist.LastName);
            Command.Parameters.AddWithValue("@Age", receptionist.Age);
            Command.Parameters.AddWithValue("@address", receptionist.Address);
            Command.Parameters.AddWithValue("@qalification", receptionist.Qualification);
            Command.Parameters.AddWithValue("@contactNo", receptionist.ContactNo);
            Command.Parameters.AddWithValue("@BloodGroup", receptionist.BloodGroup);

            Connection.Open();
            int rowEffect = Command.ExecuteNonQuery();

            Connection.Close();

            return(rowEffect);
        }
Example #52
0
 public DataTable GetResumeActive(int userId)
 {
     try
     {
         Command.CommandText = "GetResumeActiveByUser";
         Command.CommandType = CommandType.StoredProcedure;
         Command.Parameters.AddWithValue("UserID", userId);
         Connection.Open();
         var reader    = Command.ExecuteReader();
         var dataTable = new DataTable();
         dataTable.Load(reader);
         return(dataTable);
     }
     catch (Exception exception)
     {
         Console.Write(exception.Message);
         return(null);
     }
     finally
     {
         Connection.Close();
     }
 }
        public List <DepartmentModel> DepartmentDropdownlist()
        {
            query = "SELECT * FROM DepartmentTable";

            Command = new SqlCommand(query, Connection);

            List <DepartmentModel> departments = new List <DepartmentModel>();

            Connection.Open();
            Reader = Command.ExecuteReader();
            while (Reader.Read())
            {
                DepartmentModel department = new DepartmentModel();
                department.Id   = Convert.ToInt32(Reader["Id"]);
                department.Code = Reader["Code"].ToString();


                departments.Add(department);
            }
            Reader.Close();
            Connection.Close();
            return(departments);
        }
Example #54
0
        // search by company and category both
        public List <SearchItemViewModel> GetSearchItemByCompanyAndCategoryBoth(int companyId, int categoryId)
        {
            Connection.Open();

            string query = "SELECT ItemName,AvailableQuantity,ReorderLevel,CompanyName FROM Items, Company WHERE Items.CompanyId = Company.Id and Items.CategoryId = @categoryId and Items.CompanyId= @companyId";

            Command = new SqlCommand(query, Connection);
            Command.Parameters.Add("@categoryId", categoryId);
            Command.Parameters.Add("@companyId", companyId);

            Reader = Command.ExecuteReader();

            List <SearchItemViewModel> items = new List <SearchItemViewModel>();

            // for serial
            int count = 0;

            while (Reader.Read())
            {
                SearchItemViewModel itemViewModel = new SearchItemViewModel();

                count++;

                itemViewModel.SL                = count;
                itemViewModel.ItemName          = Reader["ItemName"].ToString();
                itemViewModel.AvailableQuantity = Convert.ToInt32(Reader["AvailableQuantity"]);
                itemViewModel.ReorderLevel      = Convert.ToInt32(Reader["ReorderLevel"]);
                itemViewModel.CompanyName       = Reader["CompanyName"].ToString();

                items.Add(itemViewModel);
            }

            Reader.Close();
            Connection.Close();

            return(items);
        }
Example #55
0
        private void btnDuplicate_Click(object sender, EventArgs e)
        {
            try
            {
                Connection cnx = new Connection();
                cnx.Open(ConfigurationManager.AppSettings["K2ServerName"]);
                SourceCode.Workflow.Client.ProcessInstance pi = cnx.CreateProcessInstance(txtProcessFullName.Text);

                pi.Folio = txtFolio.Text;
                foreach (DataGridViewRow item in dgvDatafields.Rows)
                {
                    pi.DataFields[item.Cells[0].Value.ToString()].Value = item.Cells[1].Value.ToString();
                }

                cnx.StartProcessInstance(pi);
                int newProcId= pi.ID;

                cnx.Close();

                if (ddlActivities.SelectedIndex > 1)
                {
                    WorkflowManagementServer wms = new WorkflowManagementServer();
                    wms.CreateConnection();
                    wms.Connection.Open(ConfigurationManager.AppSettings["K2MgmCnxString"]);
                    wms.GotoActivity(newProcId, ddlActivities.SelectedItem.ToString());
                    wms.Connection.Close();
                }

                MessageBox.Show("L'instance à été dupliquée. (ID: " + newProcId.ToString() + ")", "PI Management");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "PI Manager eror");
            }

        }
Example #56
0
        /// <summary>
        /// 审批流程
        /// </summary>
        /// <param name="userName"></param>
        /// <param name="sn"></param>
        /// <param name="actionString"></param>
        /// <param name="memo"></param>
        /// <param name="dataFields"></param>
        public WorklistItem ApprovalProcess(string userName, string sn, string actionString, string memo, Dictionary<string, string> dataFields)
        {
            Connection k2Connection = new Connection();

            try
            {
                k2Connection.Open(ConfigurationBase.Web.K2Server, ConfigurationBase.Web.K2LoginString);
                k2Connection.ImpersonateUser(userName);

                //根据SN打开工作项
                WorklistItem workList = k2Connection.OpenWorklistItem(sn);

                if (workList != null)
                {
                    #region 更新Datafield
                    if (dataFields != null && dataFields.Count > 0)
                    {
                        ProcessInstance currentProcessInst = k2Connection.OpenProcessInstance(workList.ProcessInstance.ID);
                        //更新Datafields
                        foreach (string key in dataFields.Keys)
                        {
                            if (currentProcessInst.DataFields[key] != null)
                            {
                                if (currentProcessInst.DataFields[key].Value!= dataFields[key])
                                {
                                    currentProcessInst.DataFields[key].Value = dataFields[key];
                                }
                            }
                        }
                        currentProcessInst.Update();
                    }
                    #endregion

                    #region 审批任务
                    //批量审批没有actionString,默认第一个操作
                    if (string.IsNullOrEmpty(actionString))
                    {
                        if (workList.Actions[0].Name == REJECTACTION)
                        {
                            workList.GotoActivity("流程未通过");
                        }
                        else if (workList.Actions[0].Name == UNDOACTION)
                        {
                            workList.GotoActivity("流程撤销");
                        }
                        else
                        {
                            workList.Actions[0].Execute();
                        }
                    }
                    else
                    {
                        //执行匹配的操作
                        if (actionString == UNDOACTION)
                        {
                            workList.GotoActivity("流程撤销");
                        }
                        else if (actionString == REJECTACTION)
                        {
                            workList.GotoActivity("流程未通过");
                        }
                        else
                        {
                            bool isExcuted = false;
                            for (int i = 0; i < workList.Actions.Count; i++)
                            {
                                if (workList.Actions[i].Name == actionString)
                                {
                                    workList.Actions[i].Execute();
                                    isExcuted = true;
                                    break;
                                }
                            }
                        }
                    }
                    #endregion
                }

                return workList;
            }
            catch (Exception)
            {
                return null;
            }
            finally
            {
                if (k2Connection != null)
                {
                    k2Connection.Close();
                }
            }
        }
Example #57
0
        private void ReleaseWorklistItem()
        {
            string sn = base.GetStringProperty(Constants.SOProperties.ClientWorklist.SerialNumber, true);
            ServiceObject serviceObject = base.ServiceBroker.Service.ServiceObjects[0];
            serviceObject.Properties.InitResultTable();
            DataTable results = base.ServiceBroker.ServicePackage.ResultTable;

            using (Connection k2Con = new Connection())
            {
                k2Con.Open(base.K2ClientConnectionSetup);

                WorklistItem wli = k2Con.OpenWorklistItem(sn);
                wli.Release();

                k2Con.Close();
            }
        }
Example #58
0
        private void RedirectWorklistItem()
        {
            string sn = base.GetStringProperty(Constants.SOProperties.ClientWorklist.SerialNumber, true);
            string fqn = base.GetStringProperty(Constants.SOProperties.ClientWorklist.FQN, true);

            using (Connection k2Con = new Connection())
            {
                k2Con.Open(base.K2ClientConnectionSetup);

                WorklistItem wli = k2Con.OpenWorklistItem(sn);
                wli.Redirect(fqn);

                k2Con.Close();
            }
        }
Example #59
0
        private void GetWorklist()
        {
            ServiceObject serviceObject = base.ServiceBroker.Service.ServiceObjects[0];
            serviceObject.Properties.InitResultTable();
            DataTable results = base.ServiceBroker.ServicePackage.ResultTable;

            using (Connection k2Con = new Connection())
            {
                k2Con.Open(base.K2ClientConnectionSetup);

                WorklistCriteria wc = new WorklistCriteria();
                wc.Platform = base.Platform;
                AddFieldFilters(wc);
                if (base.GetBoolProperty(Constants.SOProperties.ClientWorklist.IncludeShared) == true)
                {
                    wc.AddFilterField(WCLogical.Or, WCField.WorklistItemOwner, "Me", WCCompare.Equal, WCWorklistItemOwner.Me);
                    wc.AddFilterField(WCLogical.Or, WCField.WorklistItemOwner, "Other", WCCompare.Equal, WCWorklistItemOwner.Other);
                }
                if (base.GetBoolProperty(Constants.SOProperties.ClientWorklist.ExcludeAllocated) == true)
                {
                    wc.AddFilterField(WCLogical.And, WCField.WorklistItemStatus, WCCompare.NotEqual, WorklistStatus.Allocated);
                }
                Worklist wl = k2Con.OpenWorklist(wc);

                foreach (WorklistItem wli in wl)
                {
                    AddRowToDataTable(results, wli);
                }

                k2Con.Close();
            }
        }
Example #60
0
    protected void Page_Load(object sender, EventArgs e)
    {
         conn = new Connection();
         string connectionstring = ConfigurationManager.ConnectionStrings["connectionstring"].ConnectionString;
         conn.Open(connectionstring); 
      
        UserIPAddress = GetIPAddress();
        //For Demo            
        //UserIPAddress = "192.168.1.12";
        //UserIPAddress = Request.ServerVariables["REMOTE_ADDR"];
        Rs1 = new Recordset();
       sql1 = "Select * From Station s Left Join CVSUser u on ";

       sql1 = sql1 +  " s.LoginUser = u.UserName Where IPAddress ='" + UserIPAddress + "'";
        Rs1 = conn.Execute(sql1);
        StationID = (Rs1.Fields["Station"].Value).ToString().Trim();
        UserID = (Rs1.Fields["LoginUser"].Value).ToString().Trim();
        SecLevel = (Rs1.Fields["SecLevel"].Value).ToString().Trim();

        if (UserID == "")
        {
            Response.Redirect("Default.aspx");
        }
        Message = Request["Message"];
        Coupon_Number = Request["Coupon_Number"];
        Car_No = Request["Car_No"];
        Face_Value = Request["Face_Value"];
        Period = Request["Period"];
        //search by date
        if (Request["SDay"] != null)
        {
            SDay = Request["SDay"];
            SMonth = Request["SMonth"];
            SYear = Request["SYear"];
        }
        else
        {
            SDay = Convert.ToString(DateTime.Now.Day);
            SMonth = Convert.ToString(DateTime.Now.Month);
            SYear = Convert.ToString(DateTime.Now.Year);
        }
        if (Request["NDay"] != null)
        {
            NDay = Request["NDay"];
            NMonth = Request["NMonth"];
            NYear = Request["NYear"];
        }
        else
        {
            NDay = Convert.ToString(DateTime.Now.Day);
            NMonth = Convert.ToString(DateTime.Now.Month);
            NYear = Convert.ToString(DateTime.Now.Year);
        }
        //Search_Date = Formatdatetime(DateSerial(SYear, SMonth, SDay),2)
        //Search_NDate = Formatdatetime(DateSerial(NYear, NMonth, NDay),2)
        Search_Date = SDay + "/" + SMonth + "/" + SYear;
        Search_NDate = NDay + "/" + NMonth + "/" + NYear;
        //Response.write search_date
        //response.write SecLevel & "<br>"
        //response.write UserID

        if (Request.Form["pageid"] != null)
            pageid = (Request.Form["pageid"]).Trim();
        if (pageid == "")
        {
            pageid = "1";
        }
        if (Request.Form["Barcode"] != null)
        {
            Barcode = (Request.Form["Barcode"]).Trim().Replace("%", "%");
            Barcode = Barcode.Replace("'", "''");
            if (Barcode.Length == 15)
            {
                Face_Value = Barcode.Substring(0, 3);
                Coupon_Type = Barcode.Substring(5 - 1, 2);
                Coupon_batch = Barcode.Substring(7 - 1, 3);
                Coupon_Number = Barcode.Substring(10 - 1, 6);
            }
        }
        fsql = "select * from MasterCoupon where RequestedID = " + Convert.ToString(StationID);
        //Search Coupon Number
        //********************
        if (Barcode != "")
        {
            if (Barcode.Length == 15)
            {
                fsql = fsql + " and Coupon_Number = '" + Coupon_Number + "'";
                fsql = fsql + " and Face_Value = '" + Face_Value + "'";
                fsql = fsql + " and Coupon_Type = '" + Coupon_Type + "'";
                fsql = fsql + " and Coupon_Batch = '" + Coupon_batch + "'";
            }
            else
            {
                fsql = fsql + " and Coupon_Number LIKE '%" + Barcode + "%' ";
            }
        }
        fsql = fsql + " and  Present_Date >=   Convert(datetime, '" + Convert.ToString(Search_Date) + "', 105) ";
        fsql = fsql + " and  Present_Date < DATEADD(dd,DATEDIFF(dd,0, Convert(datetime, '" + Convert.ToString(Search_NDate) + "', 105)),0) + 1 ";
        //By UserID
        if (Convert.ToString(SecLevel).Trim() == "1")
        {
            fsql = fsql + " and Period = '" + Convert.ToString(UserID) + "' ";
        }
        fsql = fsql + " order by id desc";
        frs = new Recordset();
        frs.CursorType = (nce.adodb.CursorType)1;
        frs.LockType = (nce.adodb.LockType)1;
        Rs1.Close();
        frs.Open(fsql, conn);       
    }