Esempio n. 1
0
File: Program.cs Progetto: zmau/kaf
        private static void initDatabaseData()
        {
            PubContext dbContext = new PubContext();

            /*Role owner = new Role("administrator");
             * dbContext.Roles.Add(owner);
             * Role admin = new Role("menadžer");
             * dbContext.Roles.Add(admin);
             * Role employee = new Role("konobar");
             * dbContext.Roles.Add(employee);
             */
            dbContext.MeasureUnits.Add(new MeasureUnit()
            {
                name = "lit"
            });
            dbContext.MeasureUnits.Add(new MeasureUnit()
            {
                name = "kom"
            });
            dbContext.MeasureUnits.Add(new MeasureUnit()
            {
                name = "kg"
            });
            dbContext.MeasureUnits.Add(new MeasureUnit()
            {
                name = "dan"
            });
            dbContext.MeasureUnits.Add(new MeasureUnit()
            {
                name = "por"
            });

            dbContext.SaveChanges();
        }
Esempio n. 2
0
        private void FItemsEditor_Load(object sender, EventArgs e)
        {
            var context = new PubContext();

            BindingSource bi = new BindingSource();

            context.Items.Load();
            bi.DataSource = context.ItemGroups.Local.ToBindingList();

            dataGridViewTextBoxColumn1.Visible    = false;
            dataGridViewTextBoxColumn2.HeaderText = "Naziv";

            groupColumn.HeaderText       = "Grupa";
            groupColumn.DataSource       = context.ItemGroups.ToList();
            groupColumn.DisplayMember    = "name";
            groupColumn.ValueMember      = "Id";
            groupColumn.DataPropertyName = "group_Id";

            typeColumn.HeaderText       = "Tip";
            typeColumn.DataSource       = context.ItemTypes.ToList();
            typeColumn.DisplayMember    = "name";
            typeColumn.ValueMember      = "Id";
            typeColumn.DataPropertyName = "type_Id";

            measureUnitColumn.HeaderText       = "JM";
            measureUnitColumn.DataSource       = context.MeasureUnits.ToList();
            measureUnitColumn.DisplayMember    = "name";
            measureUnitColumn.ValueMember      = "Id";
            measureUnitColumn.DataPropertyName = "measureUnit_Id";

            dataGridViewTextBoxColumn6.Visible = false;

            dataGridViewTextBoxColumn7.HeaderText = "Cena 1";
            dataGridViewTextBoxColumn8.HeaderText = "Cena 2";
        }
Esempio n. 3
0
        private void FItemGroupEditor_Load(object sender, EventArgs e)
        {
            try {
                var           context = new PubContext();
                BindingSource bi      = new BindingSource();
                context.ItemGroups.Load();
                bi.DataSource                       = context.ItemGroups.Local.ToBindingList();
                dataGridView1.DataSource            = bi;
                dataGridView1.Columns[0].Visible    = false;
                dataGridView1.Columns[1].HeaderText = "Naziv";
                dataGridView1.Columns[2].HeaderText = "Front pozicija";
                dataGridView1.Columns[3].Visible    = false;
                dataGridView1.Columns[4].Visible    = false;
                dataGridView1.Columns[5].Visible    = false;
                dataGridView1.Columns[6].Visible    = false;

                //add new button column to the DataGridView
                //This column displays a delete icon in each row
                DataGridViewImageColumn btnRemove = new DataGridViewImageColumn();
                btnRemove.Image        = Properties.Resources.delete_icon;
                btnRemove.Width        = 20;
                btnRemove.AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
                dataGridView1.Columns.Add(btnRemove);
            }
            catch (NotSupportedException ex) {
                Console.WriteLine(ex.Message);
            }
        }
Esempio n. 4
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (!inEditMode)
            {
                userToEdit = new User();
            }

            userToEdit.name     = txtName.Text;
            userToEdit.userName = txtUserName.Text;
            if (!txtPassword.Text.Equals(""))
            {
                userToEdit.password = txtPassword.Text;
            }
            userToEdit.cardCode = txtCode.Text;
            userToEdit.role     = (Role)cmbRole.SelectedItem;

            if (!inEditMode)
            {
                PubContext.getInstance().Users.Add(userToEdit);
            }
            try {
                PubContext.getInstance().SaveChanges();
            }
            catch (System.Data.Entity.Infrastructure.DbUpdateException ex) {
                Exception cause = ex.GetBaseException();
                Console.Write(cause.Data);
            }
            Close();
        }
Esempio n. 5
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            try
            {
                Common.Transfer Trans   = new Common.Transfer();
                HttpRequest     Request = context.Request;

                Trans.Class   = "HKParkCostInfo";
                Trans.Command = "TempPayFees";
                //获取content内容
                System.IO.Stream s = System.Web.HttpContext.Current.Request.InputStream;
                byte[]           b = new byte[s.Length];
                s.Read(b, 0, (int)s.Length);
                string ContentStr = System.Text.Encoding.UTF8.GetString(b);
                if (ContentStr != "")
                {
                    Trans.Attribute = ContentStr;
                }
                PubContext.Operate(ref Trans);

                context.Response.Write(Trans.Output());
            }
            catch (Exception ex)
            {
                context.Response.Write(new ApiResult(false, ex.Message + Environment.NewLine + ex.StackTrace).toJson());
            }
        }
Esempio n. 6
0
 private void txtSearchBox_TextChanged(object sender, EventArgs e)
 {
     gridUsers.DataSource = new BindingList <User>(
         PubContext.getInstance().Users.Local.ToBindingList().Where(
             user => user.name.StartsWith(txtSearchBox.Text)
             ).ToList <User>()
         );
 }
Esempio n. 7
0
 public FUserEditor()
 {
     InitializeComponent();
     //ChangeLanguage("sr-Latn");
     cmbRole.Items.AddRange(PubContext.getInstance().Roles.ToArray());
     if (cmbRole.Items.Count > 0)
     {
         cmbRole.SelectedIndex = 0;
     }
 }
Esempio n. 8
0
        private void removeGroup(int id)
        {
            ItemGroup groupToRemove = PubContext.getInstance().ItemGroups.First(group => group.id == id);

            if (groupToRemove != null)
            {
                PubContext.getInstance().ItemGroups.Remove(groupToRemove);
                PubContext.getInstance().SaveChanges();
            }
        }
Esempio n. 9
0
        private void addGroup(String pname, int pfrontPosition, String pfrontPic, int ppicture, int pcolor, int ptype)
        {
            ItemGroup newGroup = new ItemGroup {
                name          = pname,
                frontPosition = pfrontPosition,
                frontPic      = pfrontPic,
                picture       = ppicture,
                color         = pcolor,
                type          = ptype
            };

            PubContext.getInstance().ItemGroups.Add(newGroup);
            PubContext.getInstance().SaveChanges();
        }
Esempio n. 10
0
 public FUsersEditor()
 {
     try {
         InitializeComponent();
         PubContext pubContext = PubContext.getInstance();
         pubContext.Users.Load();
         gridUsers.DataSource = pubContext.Users.Local.ToBindingList();
         Show();
     }
     catch (SqlException e) {
         Console.WriteLine(e.StackTrace.ToString());
         throw e;
     }
 }
Esempio n. 11
0
        private void FItemEditor_Load(object sender, EventArgs e)
        {
            Item artikl = PubContext.getInstance().Items.First(item => item.id == itemID);

            if (artikl != null)
            {
                txtID.Text   = Convert.ToString(artikl.id);
                txtName.Text = artikl.name;
                cmbGroup.Items.AddRange(PubContext.getInstance().ItemGroups.ToArray());
                cmbGroup.SelectedItem = artikl.group;
                cmbType.Items.AddRange(PubContext.getInstance().ItemTypes.ToArray());
                cmbType.SelectedItem = artikl.type;
                cmbMeasureUnit.Items.AddRange(PubContext.getInstance().MeasureUnits.ToArray());
                cmbMeasureUnit.SelectedItem = artikl.measureUnit;
                cbIzbacen.Checked           = artikl.izbacen;
            }
        }
Esempio n. 12
0
        public void ProcessRequest(HttpContext context)
        {
            Common.Transfer Trans = new Common.Transfer();

            //密钥类型
            //不同调用者密钥不同
            string MacType = "";

            HttpRequest Request = context.Request;

            Trans.Class   = Request["Class"].ToString();
            Trans.Command = Request["Command"].ToString();
            Trans.Mac     = Request["Mac"].ToString();

            if (Request["ComCode"] != null)
            {
                MacType = Request["ComCode"].ToString();
            }
            PubContext.OperateRSA(ref Trans, MacType);
            context.Response.ContentType = "text/plain";
            context.Response.AddHeader("Access-Control-Allow-Origin", "*");
            context.Response.Write(Trans.Output());
        }
Esempio n. 13
0
        private void RecordOperationLog(Transfer transNew1)
        {
            Common.Transfer tranNew2 = new Transfer()
            {
                Result     = transNew1.Result,
                Attribute  = transNew1.Attribute,
                Command    = transNew1.Command,
                Class      = transNew1.Class,
                Mac        = transNew1.Mac,
                QYID       = transNew1.QYID,
                QYUnitType = transNew1.QYUnitType,
                ClassLog   = transNew1.Class,
                CommandLog = transNew1.Command
            };

            tranNew2.Class   = "RecordClientInfo";
            tranNew2.Command = "RecordOperationLog";
            var HashString = tranNew2.Attribute.ToString() + DateTime.Now.ToString("yyyyMMdd") + "20200110Client";

            tranNew2.Mac = AppPKI.getMd5Hash(HashString);

            PubContext.Operate(ref tranNew2);
        }
 public ManagerController(PubContext context)
 {
     this.context = context;
 }
Esempio n. 15
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            context.Response.AddHeader("Access-Control-Allow-Origin", "*");
            try
            {
                Common.Transfer Trans = new Common.Transfer();

                HttpRequest Request = context.Request;
                if (!Request.Params.AllKeys.Contains("Class"))
                {
                    context.Response.Write(new ApiResult(false, "缺少参数Class").toJson());
                    return;
                }
                Trans.Class = Request["Class"].ToString();
                if (string.IsNullOrEmpty(Trans.Class))
                {
                    context.Response.Write(new ApiResult(false, "Class不能为空").toJson());
                    return;
                }
                if (!Request.Params.AllKeys.Contains("Command"))
                {
                    context.Response.Write(new ApiResult(false, "缺少参数Command").toJson());
                    return;
                }
                Trans.Command = Request["Command"].ToString();

                if (string.IsNullOrEmpty(Trans.Command))
                {
                    context.Response.Write(new ApiResult(false, "Command不能为空").toJson());
                    return;
                }

                if (!Request.Params.AllKeys.Contains("Mac"))
                {
                    context.Response.Write(new ApiResult(false, "缺少参数Mac").toJson());
                    return;
                }
                Trans.Mac = Request["Mac"].ToString();
                if (string.IsNullOrEmpty(Trans.Mac))
                {
                    context.Response.Write(new ApiResult(false, "Mac不能为空").toJson());
                    return;
                }
                //获取content内容
                System.IO.Stream s = System.Web.HttpContext.Current.Request.InputStream;
                byte[]           b = new byte[s.Length];
                s.Read(b, 0, (int)s.Length);
                string ContentStr = System.Text.Encoding.UTF8.GetString(b);
                if (ContentStr != "")
                {
                    Trans.Agreement = ContentStr;
                }
                PubContext.Operate(ref Trans);

                Compress(context);
                context.Response.Write(Trans.Output());
            }
            catch (Exception ex)
            {
                context.Response.Write(new ApiResult(false, ex.Message + Environment.NewLine + ex.StackTrace).toJson());
            }
        }
Esempio n. 16
0
 public EmployeeController(PubContext context, IMapper mapper)
 {
     this.context = context;
     this.mapper  = mapper;
 }
Esempio n. 17
0
 public FeedBackRepository(PubContext pubContext)
 {
     _pubContext = pubContext;
 }
Esempio n. 18
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            context.Response.AddHeader("Access-Control-Allow-Origin", "*");
            try
            {
                Common.Transfer Trans = new Common.Transfer();

                HttpRequest Request = context.Request;
                if (!Request.Params.AllKeys.Contains("Class"))
                {
                    context.Response.Write(new ApiResult(false, "缺少参数Class").toJson());
                    return;
                }

                //获取要执行的类名称
                Trans.Class = Request["Class"].ToString();
                if (string.IsNullOrEmpty(Trans.Class))
                {
                    context.Response.Write(new ApiResult(false, "Class不能为空").toJson());
                    return;
                }
                if (!Request.Params.AllKeys.Contains("Command"))
                {
                    context.Response.Write(new ApiResult(false, "缺少参数Command").toJson());
                    return;
                }

                //wlg 20191204 没有地方使用???
                if (Request["QYID"] != null)
                {
                    Trans.QYID = Request["QYID"].ToString();
                }

                //wlg 20191204 没有地方使用???
                if (Request["QYUnitType"] != null)
                {
                    Trans.QYUnitType = Request["QYUnitType"].ToString();
                }

                //获取命令类型
                Trans.Command = Request["Command"].ToString();

                if (string.IsNullOrEmpty(Trans.Command))
                {
                    context.Response.Write(new ApiResult(false, "Command不能为空").toJson());
                    return;
                }
                if (Request.Params.AllKeys.Contains("Agreement"))
                {
                    Trans.Agreement = HttpUtility.UrlDecode(Request["Agreement"].ToString());//碧桂园 获取协议html代码
                }

                //获取属性xml格式字符串
                if (!Request.Params.AllKeys.Contains("Attribute"))
                {
                    context.Response.Write(new ApiResult(false, "缺少参数Attribute").toJson());
                    return;
                }
                Trans.Attribute = HttpUtility.UrlDecode(Request["Attribute"].ToString());
                if (string.IsNullOrEmpty(Trans.Attribute))
                {
                    context.Response.Write(new ApiResult(false, "Attribute不能为空").toJson());
                    return;
                }

                if (!Request.Params.AllKeys.Contains("Mac"))
                {
                    context.Response.Write(new ApiResult(false, "缺少参数Mac").toJson());
                    return;
                }
                Trans.Mac = Request["Mac"].ToString();
                if (string.IsNullOrEmpty(Trans.Mac))
                {
                    context.Response.Write(new ApiResult(false, "Mac不能为空").toJson());
                    return;
                }


                //如果是文件类型
                if (Trans.Class == "Files")
                {
                    new Files().ProcessRequest(context);
                }
                else
                {
                    //wlg 20200110 增加操作日志记录
                    Common.Transfer tranNew = new Transfer()
                    {
                        Result     = Trans.Result,
                        Attribute  = Trans.Attribute,
                        Command    = Trans.Command,
                        Class      = Trans.Class,
                        Mac        = Trans.Mac,
                        QYID       = Trans.QYID,
                        QYUnitType = Trans.QYUnitType
                    };
                    RecordOperationLog(tranNew);

                    PubContext.Operate(ref Trans);
                }

                Compress(context);
                context.Response.Write(Trans.Output());
            }
            catch (Exception ex)
            {
                context.Response.Write(new ApiResult(false, ex.Message + Environment.NewLine + ex.StackTrace).toJson());
            }
        }
Esempio n. 19
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            context.Response.AddHeader("Access-Control-Allow-Origin", "*");
            try
            {
                Common.Transfer Trans = new Common.Transfer();

                HttpRequest Request = context.Request;
                Dictionary <string, string> param = new Dictionary <string, string>();
                foreach (string key in Request.Form.AllKeys)
                {
                    param.Add(key, Request.Params[key]);
                }
                if (!param.ContainsKey("Class"))
                {
                    context.Response.Write(new ApiResult(false, "缺少参数Class").toJson());
                    return;
                }
                Trans.Class = param["Class"].ToString();
                if (string.IsNullOrEmpty(Trans.Class))
                {
                    context.Response.Write(new ApiResult(false, "Class不能为空").toJson());
                    return;
                }
                if (!param.ContainsKey("Command"))
                {
                    context.Response.Write(new ApiResult(false, "缺少参数Command").toJson());
                    return;
                }
                Trans.Command = param["Command"].ToString();

                if (string.IsNullOrEmpty(Trans.Command))
                {
                    context.Response.Write(new ApiResult(false, "Command不能为空").toJson());
                    return;
                }

                string json = JsonConvert.SerializeObject(new { Attribute = param });
                Trans.Attribute = JsonConvert.DeserializeXmlNode(json).OuterXml;
                if (string.IsNullOrEmpty(Trans.Attribute))
                {
                    context.Response.Write(new ApiResult(false, "Attribute不能为空").toJson());
                    return;
                }
                PubInfo Rp         = (PubInfo)Assembly.Load("Business").CreateInstance("Business." + Trans.Class);
                var     HashString = Trans.Attribute.ToString() + DateTime.Now.ToString("yyyyMMdd") + Rp.Token;
                var     Mac        = AppPKI.getMd5Hash(HashString);
                Trans.Mac = Mac;
                if (Trans.Class == "Files")
                {
                    new Files().ProcessRequest(context);
                }
                else
                {
                    PubContext.Operate(ref Trans);
                }

                Compress(context);
                context.Response.Write(Trans.Output());
            }
            catch (Exception ex)
            {
                context.Response.Write(new ApiResult(false, ex.Message + Environment.NewLine + ex.StackTrace).toJson());
            }
        }
 public DbInitializerService(PubContext context)
 {
     this.context = context;
 }